Randomize in JavaScript

I cannot randomize my variable. Can someone please tell me why? My code is: var fish = math.random What is wrong?

1/13/2018 9:26:09 PM


3 Answers

New Answer


Math.random() instead of math.random. This will return a value between 0 and 1.


Math.random (you must use 'Math' and not 'math') refer to the method itself of Math object... if you want to run it, you need to append a parenthesis pair to it for calling it, else you only assign the method reference and not the computed value ^^


Thank You!