Advertisement
Spocoman

01. Sum Seconds

Dec 16th, 2021 (edited)
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function sumSeconds(input) {
  2.     let firstTime = parseInt(input[0]);
  3.     let secondTime = parseInt(input[1]);
  4.     let thirdTime = parseInt(input[2]);
  5.     let total = firstTime + secondTime + thirdTime;
  6.     let minutes = Math.floor(total / 60);
  7.     let seconds = total % 60;
  8.  
  9.     if (seconds < 10) {
  10.         console.log(`${minutes}:0${seconds}`);
  11.     } else {
  12.         console.log(`${minutes}:${seconds}`);
  13.     }
  14. }
  15.  
  16. Taрикатско решение:)
  17.  
  18. function sumSeconds(input) {
  19.    
  20.     let total = parseInt(input[0]) + parseInt(input[1]) + parseInt(input[2]);
  21.    
  22.     console.log(`${Math.floor(total / 60)}:${total % 60 < 10? '0' : ''}${total % 60}`);
  23.    
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement