Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function Exam(input){
- let hourExam = Number(input.shift());
- let minutesExam = Number(input.shift());
- let hourArrived = Number(input.shift());
- let minutesArrived = Number(input.shift());
- let examtotalMins = hourExam * 60 + minutesExam;//subirat se minutite
- let arrtotalMins = hourArrived * 60 + minutesArrived;
- let time = examtotalMins - arrtotalMins;
- if(time < 0){
- console.log('Late');
- if(time > -60){
- console.log(`${Math.abs(time)} minutes after the start`);
- }else{
- let h = Math.abs(parseInt(time / 60));//chasovete
- let m = Math.abs(time % 60);// ostatuk na time sa minutite.
- if(m < 10){
- console.log(`${h}:0${m} hours after the start`);
- }else{
- console.log(`${h}:${m} hours after the start`);
- }
- }
- }else if(time === 0 || time <= 30){
- console.log('On time');
- if(time > 0){
- console.log(`${time} minutes before the start`);
- }
- }else {
- console.log('Early');
- if(time < 60){
- console.log(`${time} minutes before the start`);
- }else{
- let h = parseInt(time/60);
- let m = time % 60;
- if(m < 10){
- console.log(`${h}: 0${m} hours before the start`);
- }else{
- console.log(`${h}: ${m} hours before the start`);
- }
- }
- }
- }
- Exam([9,30,9,50]);
- Exam([9,00,8,30]);
- Exam([16,00,15,00]);
- Exam([10,00,10,00]);
Advertisement
Add Comment
Please, Sign In to add comment