If you're going to write a wrapper function for testing, make sure it can't be hijacked by solver ( defining it with const is one way to do that ).
Native Math does not have enumerable properties. In keeping with this, and to teach good habits, defined methods should not be enumerable, and this should be tested for.
toFixed does rounding differently from Math.round ( and weirdly in general ). This behaviour should be warned for and toFixed should ideally be discouraged and tested against.
Rounding is not the appropriate solution for floating point representation inaccuracy. This has been dissed as an issue below, but again, it's teaching bad habits.
What kind of rounding is expected for values ending with 5?
Existing solutions return different results for Math.toRadians(-60.87676573264997) and they all pass the tests.
Are you sure those are actually numbers?
This comment is hidden because it contains spoiler information about the solution
Julia translation
Added limited random tests ( expected value
true
will be generated exceedingly rarely. relying on fixed tests for that ).Smile, you missed an edge condition where you're returning
NaN
instead ofnull
. You're not going to fix that anymore, I know. :PAnd approved.
This comment is hidden because it contains spoiler information about the solution
If you're going to write a wrapper function for testing, make sure it can't be hijacked by solver ( defining it with
const
is one way to do that ).Native
Math
does not have enumerable properties. In keeping with this, and to teach good habits, defined methods should not be enumerable, and this should be tested for.toFixed
does rounding differently fromMath.round
( and weirdly in general ). This behaviour should be warned for andtoFixed
should ideally be discouraged and tested against.Rounding is not the appropriate solution for floating point representation inaccuracy. This has been dissed as an issue below, but again, it's teaching bad habits.
Not an issue
Updated description.
This is fixed, though not ideal.
What kind of rounding is expected for values ending with
5
?Existing solutions return different results for
Math.toRadians(-60.87676573264997)
and they all pass the tests.No really integers...
Exact comparison isn't appropriate here due to possible floating point errors.
His point there is that saying that if it is a number and not a string, does it make sense to say things like don't pad or return the decimal.
Description modified.
Duplicate.
Since when is input validation required? ;-)
Also descriptions has been updated
Loading more items...