r/javascript • • Aug 27 '16

Is your JavaScript function actually pure?

http://staltz.com/is-your-javascript-function-actually-pure.html
8 Upvotes

48 comments sorted by

View all comments

13

u/reeferd Aug 27 '16

If the input to a function always is random, then the input is never the same - or am I missing something here?

1

u/ChronoChris Aug 27 '16

assignment and calculation of the Math.random should be done when you instantiate math.random to the variable. It shouldn't be every time the multiplication is ran on the variable.