Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function exam([arg1, arg2, arg3, arg4]) {
- let examHour = Number(arg1);
- let exanMin = Number(arg2);
- let arriveHour = Number(arg3);
- let arriveMin = Number(arg4);
- let examTime = examHour * 60 + exanMin;
- let arriveTime = arriveHour * 60 + arriveMin;
- let totalMinutesDifference = arriveTime - examTime;
- let secondDiff = examTime - arriveTime;
- if (totalMinutesDifference <= 59 && totalMinutesDifference > 0) {
- console.log('Early');
- } else if (totalMinutesDifference >= 30) {
- console.log('On time');
- }
- if (totalMinutesDifference != 0) {
- let hoursDifference = Math.abs(totalMinutesDifference / 60);
- let minutesDifference = Math.abs(totalMinutesDifference % 60);
- if (minutesDifference > 0) {
- console.log(minutesDifference + ' minutes before the start');
- } else if (hoursDifference) {
- console.log(`${hoursDifference}:${minutesDifference}` + ' hours before the start');
- }
- if (totalMinutesDifference < 0) {
- console.log(`${minutesDifference}` + ' minutes after the start');
- } else {
- console.log(`${hoursDifference}:${minutesDifference}` + ' hours after the start');
- }
- }
- exam(['9', '30', '9', '50']);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement