Created
March 25, 2021 16:39
-
-
Save deepak-terse/a9e07565c6d0656100ad38092a7ab6bd to your computer and use it in GitHub Desktop.
Time Convert
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Problem Statement: | |
- Have the function TimeConvert(num) take the num parameter being passed and return the number of hours and minutes the parameter converts to (ie. if num = 63 then the output should be 1:3). Separate the number of hours and minutes with a colon. | |
Examples | |
Input: 126 | |
Output: 2:6 | |
Input: 45 | |
Output: 0:45 | |
*/ | |
function TimeConvert(num) { | |
if (num > 0) return Math.floor(num/60) + ":" + num%60; | |
else return "Invalid time"; | |
} | |
// keep this function call here | |
console.log(TimeConvert(readline())); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment