Created
May 1, 2018 05:45
-
-
Save Luke-Rogerson/f5b2f40489cde59c169430192c5cc9cc to your computer and use it in GitHub Desktop.
TimeConvert algorithm challenge created by Luke_Rogerson - https://repl.it/@Luke_Rogerson/TimeConvert-algorithm-challenge
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
/* | |
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. | |
Input:126 | |
Output:"2:6" | |
Input:45 | |
Output:"0:45" | |
*/ | |
// If (input / 60) < 1 | |
// return (0 + ":" + input) | |
// Else if (input / 60) > 1) | |
// return ((input/60.slice[0])+(input%60) | |
function TimeConvert (num) { | |
if ((num / 60) < 1 ) { | |
return (0 + ":" + num); | |
} | |
else if ((num / 60) > 1) { | |
return (Math.floor(num / 60)) + ":" + (num % 60); | |
} | |
} | |
TimeConvert(512); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment