Skip to content

Instantly share code, notes, and snippets.

@deepak-terse
Created March 25, 2021 16:39
Show Gist options
  • Save deepak-terse/a9e07565c6d0656100ad38092a7ab6bd to your computer and use it in GitHub Desktop.
Save deepak-terse/a9e07565c6d0656100ad38092a7ab6bd to your computer and use it in GitHub Desktop.
Time Convert
/*
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