Skip to content

Commit

Permalink
Merge pull request #5 from Aleksandr-Anokhin/module5-task2
Browse files Browse the repository at this point in the history
  • Loading branch information
keksobot authored Oct 17, 2024
2 parents 612b4f1 + 9013e93 commit 7308363
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions js/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,21 @@ const palindrome = str => {
const str = 'level';
const isPalindrome = palindrome(str);
console.log (isPalindrome);

// Функция подсчета времени

const parseTime = (time) => {
const splited = time.split(':');
return parseInt(splited[0], 10) * 60 + parseInt(splited[1], 10);
};

const timeFrame = (startWorkingDay, endWorkingDay, startMeeting, durationMeeting) => {
const startDayMin = parseTime(startWorkingDay);
const endDayMin = parseTime(endWorkingDay);
const startMeetingMin = parseTime(startMeeting);
const meetingEndMin = startMeetingMin + durationMeeting;
return startDayMin <= startMeetingMin && meetingEndMin <= endDayMin;
}

console.log (timeFrame('8:0', '10:0', '8:0', 120)); // true
console.log (timeFrame('8:00', '17:30', '08:00', 900)); // false

0 comments on commit 7308363

Please sign in to comment.