1 //Random word generator 2 let sounds = ["bl", "ue", "r", "ed", "or", "an", "ge", "yel", "low", "gr", "een", "pur", "ple"]; 3 while (true) 4 { 5 let newSound = prompt("Type in a sound or leave blank to continue."); 6 if (!newSound) 7 { 8 break; 9 } 10 sounds.push(newSound); 11 } 12 13 let numSounds = Math.floor(Math.random() * 5) + 2; 14 let word = ""; 15 16 for (let i = 0; i < numSounds; i++) 17 { 18 let index = Math.floor(Math.random() * sounds.length); 19 let sound = sounds[index]; 20 word += sound; 21 sounds.splice(index, 1); 22 } 23 alert(word); 24