+ 2

Why does "var MATH = Math.floor(Math.random(33)); document.write(MATH)" write 0?

CODE: var MATH = Math.floor(Math.random(33)); document.write(MATH) WHY: I wanted to test it out

3rd Oct 2018, 6:48 PM
Potato Hacker
Potato Hacker - avatar
1 Answer
+ 4
Math.random() does not accept any parameters since "random()" is only a method to the "Math" object and not a function. instead, use "var MATH = (Math.random()*33).toFixed(0)" to generate a random integer value from "0 - 32" inclusively.
3rd Oct 2018, 7:05 PM
Nomeh Uchenna Gabriel
Nomeh Uchenna Gabriel - avatar