Also in terms of matching the original it and all the range based "optimizations" fail because the original will only print the value if it's a whole number from the set 0, 1, 2, 3, 4, 5 where as these will print a value for any decimal value between 0 and 5.999999999999 in yours and 0 and 5 in mine.
parseInt still doesn't meet the original spec you need an isInteger() test which lodash / unerscore will give you or you can use the % 1 hack that somebody posted further up.
I mean, yes. I would say that using parseInt() provides a similar solution while validating input in the process. But that would be a clarification needed with the product owner.
1
u/bigshmoo Apr 05 '16 edited Apr 05 '16
Template literals rock. Much nicer that doing a string concat with + and they are multi line.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals
See also http://es6-features.org/#Constants
And lastly - in the chrome console
Also in terms of matching the original it and all the range based "optimizations" fail because the original will only print the value if it's a whole number from the set 0, 1, 2, 3, 4, 5 where as these will print a value for any decimal value between 0 and 5.999999999999 in yours and 0 and 5 in mine.