Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solve(arr) {
- var x = Number(arr[0]);
- var y = Number(arr[1]);
- var z = Number(arr[2]);
- var totalSeconds = x + y + z;
- // console.log(totalSeconds);
- var hours = Math.floor(totalSeconds / 60);
- // console.log(hours);
- var seconds = totalSeconds - hours * 60;
- // console.log(seconds);
- var result = "";
- if (seconds < 10) {
- seconds = "0" + seconds;
- }
- if (totalSeconds >= 0 && totalSeconds <= 59) {
- result = "0:" + seconds;
- console.log(result);
- }
- else if (totalSeconds >= 60 && totalSeconds <= 119) {
- result = "1:" + seconds;
- console.log(result);
- }
- else if (totalSeconds >= 120 && totalSeconds <= 179) {
- result = "2:" + seconds;
- console.log(result);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement