Skip to content

Commit

Permalink
Merge pull request #5 from Armine999/module5-task1
Browse files Browse the repository at this point in the history
  • Loading branch information
keksobot authored Nov 7, 2024
2 parents f949c5d + 0477e73 commit 3555c8d
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions js/function.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,30 @@ console.log(cutNumbers('asdasdasd'))

// task 4

// '8:00' - начало рабочего дня startWork
// '17:30' - конец рабочего дня endWork
// '14:00' - начало встречи meetingStart
// 90 - продолжительность встречи в минутах meetingDiraction

const timeInMinutes = (timeInHour = '') => {
const [hour, minut] = timeInHour.split(':');
return hour * 60 + Number(minut);
}

const isMeetInLimit = (startWork, endWork, meetingStart, meetingDiraction) => {
const startWorkInMinutes = timeInMinutes(startWork);
const endWorkInMinutes = timeInMinutes(endWork);
const meetingStartInMinutes = timeInMinutes(meetingStart);
const meetingendInMinutes = timeInMinutes(meetingStart) + meetingDiraction;

return (meetingStartInMinutes >= startWorkInMinutes && meetingendInMinutes <= endWorkInMinutes)
}
console.log(isMeetInLimit('08:00', '17:30', '14:00', 90)); //true
console.log(isMeetInLimit('8:0', '10:0', '8:0', 120)); //true
console.log(isMeetInLimit('08:00', '14:30', '14:00', 90)); //false
console.log(isMeetInLimit('14:00', '17:30', '08:0', 90)); //false
console.log(isMeetInLimit('8:00', '17:30', '08:00', 900)); //false




Expand Down

0 comments on commit 3555c8d

Please sign in to comment.