Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solve(hourS, minS, hourA, minA) {
- hourS=+hourS;
- hourA=+hourA;
- minS=+minS;
- minA=+minA;
- let rmS= hourS*60+minS;
- let rmA= hourA*60+minA;
- let late=rmA-rmS;
- let early= rmS-rmA;
- let hhA=Math.floor((rmA-rmS)/60);
- let mindiflate=minA-minS;
- if (rmS<rmA) {
- console.log ("Late");
- if (rmS+60>rmA) {
- console.log(`${late} minutes after the start`);
- } else {
- if (minA>=minS) {
- console.log (`${hhA}:${mindiflate} hours after the start`)
- } else {
- mindiflate+=60;
- console.log (`${hhA}:${mindiflate} hours after the start`);
- }
- }}
- else if ((rmA+30>=rmS) && (rmS>=rmA)) {
- console.log ("On time");
- if (rmA!==rmS) {
- console.log (`${early} minutes before the start`);
- }
- }
- else if ((rmA+30<rmS) && (rmS>=rmA)) {
- console.log ("Early");
- if ((early<60) && (early>=10)) {
- console.log (`${early} minutes before the start`);
- } else if (early>=60) {
- let h=Math.floor(early/60);
- let m=early%60;
- if (m<10) {
- console.log (`${h}:0${m} hours before the start`);
- } else {
- console.log (`${h}:${m} hours before the start`);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement