Skip to content

Commit 72136d4

Browse files
authored
Merge pull request #4 from Elvira-Nikolenko/module5-task1
2 parents be2e278 + f5b8237 commit 72136d4

File tree

14 files changed

+18
-28
lines changed

14 files changed

+18
-28
lines changed

index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,6 @@ <h2 class="data-error__title">Не удалось загрузить данны
234234
</section>
235235
</template>
236236
<script src="js/functions.js"></script>
237-
<script src="js/main.js"></script>
237+
<script type="module" src="js/main.js"></script>
238238
</body>
239239
</html>

js/api.js

Whitespace-only changes.

js/big-picture.js

Whitespace-only changes.

js/constants.js

Whitespace-only changes.

js/data-loader.js

Whitespace-only changes.

js/effects.js

Whitespace-only changes.

js/filters.js

Whitespace-only changes.

js/functions.js

Lines changed: 17 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,22 @@
1-
function checkStringLength(str, maxLength) {
2-
return str.length <= maxLength;
3-
}
4-
checkStringLength('тест', 5);
5-
6-
function isPalindrome(str) {
7-
const normalizedStr = str.replaceAll(' ', '').toLowerCase();
8-
let reversedStr = '';
9-
for (let i = normalizedStr.length - 1; i >= 0; i--) {
10-
reversedStr += normalizedStr[i];
1+
function workTime(workStart, workEnd, meetingStart, meetingDuration) {
2+
const timeRegex = /^([01]?[0-9]|2[0-3]):[0-5][0-9]$/;
3+
if (!timeRegex.test(workStart) || !timeRegex.test(workEnd) || !timeRegex.test(meetingStart)) {
4+
throw new Error('Некорректный формат времени. Ожидается HH:MM.');
115
}
12-
return normalizedStr === reversedStr;
13-
}
6+
const parseTime = (timeStr) => {
7+
const [hours, minutes = '0'] = timeStr.split(':').map(Number);
8+
return hours * 60 + minutes;
9+
};
1410

15-
isPalindrome('тест');
11+
const workStartMinutes = parseTime(workStart);
12+
const workEndMinutes = parseTime(workEnd);
13+
const meetingStartMinutes = parseTime(meetingStart);
14+
const meetingEndMinutes = meetingStartMinutes + meetingDuration;
1615

17-
function extractDigits(input) {
18-
const str = input.toString();
19-
let result = '';
20-
for (let i = 0; i < str.length; i++) {
21-
const char = str[i];
22-
if (!Number.isNaN(parseInt(char, 10))) {
23-
result += char;
24-
}
25-
}
26-
if (result === '') {
27-
return NaN;
28-
}
29-
return parseInt(result, 10);
16+
return (
17+
meetingStartMinutes >= workStartMinutes &&
18+
meetingEndMinutes <= workEndMinutes
19+
);
3020
}
3121

32-
extractDigits('кот');
22+
workTime('08:00', '18:00', '10:00', 90);

js/messages.js

Whitespace-only changes.

js/scale.js

Whitespace-only changes.

0 commit comments

Comments
 (0)