Ad
  • Default User Avatar

    'Fixed, see comments above'

  • Custom User Avatar

    Issue not specified.

  • Custom User Avatar

    Also, toFixed() gives bad behaviour sometimes; best practice to round x to the y decimal digit is to use Math.round(x*Math.power(10,y))/Math.power(10,y).

    In this case Math.round(x*100)/100 should cut it.

  • Default User Avatar

    You're returning a String, while you're expected to return a Number.

  • Custom User Avatar

    I think you meant to say that a solution with String.prototype.replace is accepted.

    Thanks for reporting, it is fixed. :)

  • Custom User Avatar

    Sorry I didn't get you. Could you be more specific?

  • Custom User Avatar

    The first thing I would recommend doing is taking a step back and evaluating you're approach to validating the inputs. Currently you're doing a lot of checks to verify that number is NOT a lot of things, when you could simplify your approach by verifying that number is in fact the type of number you expect it to be (research Ruby's numerical data types to determine which type to check for). That should allow you to clean up some of your logic a bit. As for passing the final test, I would recommend checking what value is being passed in, by logging it to the console somehow. :)