+ 1

Randomize in JavaScript

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

13th Jan 2018, 9:26 PM
YoBoi
3 odpowiedzi
+ 4
Math.random() instead of math.random. This will return a value between 0 and 1.
13th Jan 2018, 9:34 PM
The Coding Sloth
The Coding Sloth - avatar
+ 3
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 ^^
13th Jan 2018, 9:49 PM
visph
visph - avatar
+ 1
Thank You!
13th Jan 2018, 9:37 PM
YoBoi