Random Value From Array
const modes = ['walk', 'run', 'hide', 'jump', 'dance'];
const randomMode = modes[Math.floor(modes.length * Math.random())];
console.log(randomMode);
// turn it into a function:
function randomChoice(arr) {
return arr[Math.floor(arr.length * Math.random())];
}
const colors = ['red', 'green', 'blue', 'black', 'white'] ;
console.log(randomChoice(colors));
console.log(randomChoice(modes));
Grab a random value from an array.