Ad
  • Custom User Avatar

    Every character is written by me after careful thought, kata has been rigorously tested many times before release, there is no problem with my code, there is only a problem with your code!

  • Custom User Avatar

    @Blind4Basic No,you code is have some wrong.

    using mycode:

    addTime("90 sec","0.5 min","minute")
    1.5
    
  • Custom User Avatar

    See!

    addTime("1045312318272019 sec","104531231827.2019 min","hour")
    292106720050.45526
    addTime("104531231827.2019 min","1045312318272019 sec","hour")
    292106720050.45526
    
  • Custom User Avatar
    function addTime(time1, time2, format) {
      const timeInSeconds = convertToSeconds(time1) + convertToSeconds(time2);
    
      if (format === "second") {
        return timeInSeconds;
      } else if (format === "minute") {
        return timeInSeconds / 60;
      } else if (format === "hour") {
        return timeInSeconds / 3600;
      } else if (format === "day") {
        return timeInSeconds / (3600 * 24);
      } else {
        return "Invalid format";
      }
    }
    
    function convertToSeconds(time) {
      const [value, unit] = time.split(" ");
      if (unit === "sec") {
        return parseInt(value);
      } else if (unit === "min") {
        return parseInt(value) * 60;
      } else if (unit === "hour") {
        return parseInt(value) * 3600;
      } else if (unit === "day") {
        return parseInt(value) * 86400;
      }
    }
    
  • Custom User Avatar

    There is something wrong with your code, using my code you can pass the

  • Custom User Avatar

    It's hard to add random tests, my tests are sufficient, the random and sample tests you mentioned don't apply to this kata

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar
  • Custom User Avatar

    No, that's correct

  • Custom User Avatar

    OK,i am fixing now

  • Custom User Avatar

    OK,i am fixing now

  • Custom User Avatar

    Please allow to translate or make more language's version

  • Custom User Avatar

    Please describe the problem in detail (a complete problem contains: what the problem is, suggestions for solving it, etc.)

  • Custom User Avatar

    Thanks, now i fix

  • Custom User Avatar

    Similar, but a lot of things are different, for example, mine makes a requirement for the value digit bit, of course, I'm not taking the bull by the horns, thanks for the reminder, I'll pay attention to it in the future when I create the Kata

  • Loading more items...