Skip to content

Commit 7308363

Browse files
authored
Merge pull request #5 from Aleksandr-Anokhin/module5-task2
2 parents 612b4f1 + 9013e93 commit 7308363

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

js/functions.js

+18
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,21 @@ const palindrome = str => {
3333
const str = 'level';
3434
const isPalindrome = palindrome(str);
3535
console.log (isPalindrome);
36+
37+
// Функция подсчета времени
38+
39+
const parseTime = (time) => {
40+
const splited = time.split(':');
41+
return parseInt(splited[0], 10) * 60 + parseInt(splited[1], 10);
42+
};
43+
44+
const timeFrame = (startWorkingDay, endWorkingDay, startMeeting, durationMeeting) => {
45+
const startDayMin = parseTime(startWorkingDay);
46+
const endDayMin = parseTime(endWorkingDay);
47+
const startMeetingMin = parseTime(startMeeting);
48+
const meetingEndMin = startMeetingMin + durationMeeting;
49+
return startDayMin <= startMeetingMin && meetingEndMin <= endDayMin;
50+
}
51+
52+
console.log (timeFrame('8:0', '10:0', '8:0', 120)); // true
53+
console.log (timeFrame('8:00', '17:30', '08:00', 900)); // false

0 commit comments

Comments
 (0)