Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function examSchedule(input) {
- let hours = Number(input[0]);
- let minutes = Number(input[1]);
- let dayPart = input[2];
- let hoursAdded = Number(input[3]);
- let minutesAdded = Number(input[4]);
- let result = (hours + hoursAdded) * 60 + minutes + minutesAdded;
- let totalHours = parseInt(result / 60 % 24);
- let totalMinutes = result % 60;
- dayPart = totalHours >= 12 ? (dayPart == "AM" ? "PM" : "AM") : dayPart;
- totalHours -= totalHours > 12 ? 12 : 0;
- console.log(`${totalHours.toString().padStart(2, '0')}:${totalMinutes.toString().padStart(2, '0')}:${dayPart}`);
- return;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement