I am trying to randomize the values in an array.
Is it acceptable to type out my code like this:
var buttonColours = ["red", "blue", "green", "yellow"];
var randomChosenColour = Math.random(buttonColours.length);
I am trying to randomize the values in an array.
Is it acceptable to type out my code like this:
var buttonColours = ["red", "blue", "green", "yellow"];
var randomChosenColour = Math.random(buttonColours.length);
No.
random()
return number between 0-1.
use Math.floor(Math.random() * buttonColours.length)