Advertisement
Didart

Sum Seconds

Mar 7th, 2022
907
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function sumSeconds(input) {
  2.  
  3.     let firstPlayer = Number(input[0]);
  4.     let secondPlayer = Number(input[1]);
  5.     let thirdPlayer = Number(input[2]);
  6.  
  7.     let sumTime = firstPlayer + secondPlayer + thirdPlayer;
  8.     let minutes = Math.floor(sumTime / 60);
  9.     let seconds = sumTime % 60;
  10.  
  11.     if (seconds < 10) {
  12.         console.log(`${minutes}:0${seconds}`);
  13.     } else {
  14.         console.log(`${minutes}:${seconds}`);
  15.     }
  16. }
  17.  
  18. sumSeconds(["35", "45", "44"])
  19.  
  20.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement