Ad
Fundamentals
Strings
Data Types
Code
Diff
  • function minutes(num){
    if(num<0)
    {
      num=-num;
    }
      const minutes = num % 60
      const hours = (num - minutes)/60
      var result="";
      
    
      result+=(hours+":");
      if(minutes<10)
      {
        result+=("0");
        result+=(minutes);
      }else{
        result+=(minutes);
      }
      return result;
    }
    console.log(minutes(120))
    • function minutes(num){
    • if(num<0)
    • {
    • num=-num;
    • }
    • const minutes = num % 60
    • const hours = (num - minutes)/60
    • return `${hours}:${("0" + minutes).slice(-2)}`
    • }
    • var result="";
    • result+=(hours+":");
    • if(minutes<10)
    • {
    • result+=("0");
    • result+=(minutes);
    • }else{
    • result+=(minutes);
    • }
    • return result;
    • }
    • console.log(minutes(120))