javascript pick a random word code example
Example 1: js random word generator
var word = ['Rock', 'Paper', 'Scissor'];
var words = word[Math.floor(Math.random()*word.length)];
alert('The computer chose:' + wors);
// Be sure to add more to the string values if you wish to add more words.
Example 2: javascript random word
// function for selecting a random index from an array
const pickOne = (arr) => arr[Math.floor(Math.random() * arr.length)];
let choice = pickOne(["Apple", "Banana", "Orange"]);