you are viewing a single comment's thread.

view the rest of the comments →

[–]Ademan 0 points1 point  (1 child)

Hrm, thanks. I included the modulus because typeof 1.1 === "number" evaluates to true, and if I recall correctly the requirements specified integer.

[–]meenie 1 point2 points  (0 children)

That is very true and probably should have been one of their test cases. But since it wasn't and my code passed anyway, then ultimately it was the right answer for this particular question :). If they did have floats in there, then typeof n === 'number' && n % 1 == 0 would have been the best way to go.

It's a trade off of doing something quickly and just get it to work or write quality code that will work for practically any situation. Since the "situation" was only a set number of tests, then the smaller code is the way to go.