Ad
Fundamentals
Strings
Data Types
Code
Diff
  • const toHours = ( i ) => Math.floor( i / 60 );
    
    const setDigits = ( i ) => i < 10 ? `0${i}` : i;
    
    const getTime = ( i ) => [toHours(i), i % 60];
    
    const toTime = ( arr ) => `${arr[0]}:${setDigits(arr[1])}`;
    
    const minutes = ( i ) => toTime(getTime(i));
    • const minutes = (n) => {
    • const hours = Math.floor(n / 60);
    • const minutes = n % 60;
    • const zeroPad = minutes < 10 ? `0` : ``;
    • return `${hours}:${zeroPad}${minutes}`;
    • }
    • const toHours = ( i ) => Math.floor( i / 60 );
    • const setDigits = ( i ) => i < 10 ? `0${i}` : i;
    • const getTime = ( i ) => [toHours(i), i % 60];
    • const toTime = ( arr ) => `${arr[0]}:${setDigits(arr[1])}`;
    • const minutes = ( i ) => toTime(getTime(i));