HTML Random Word Game Not Giving Randoms [closed]

2 weeks ago 20
ARTICLE AD BOX

I've been trying to recreate an old scrambled word game i made in HS to relearn HTML but cannot for the life of me get a randomized word from a string. I've tried looking this up, and despite numerous fixes the closest i got was code that made the word randomize every second. code is as follows:

<div class="mainbox" style="height: 600px;"> <h2 id="time", style="font-size: 48px;">00</h2> <h2 id="score", style="font-size: 36px;">0</h2> <h2 id="word", style="font-size: 60px;">Your Jumbled Words Will Appear Here!</h2> <h2 id="out1", style="font-size: 26px;">Please Select Difficulty</h2> <script> let x = document.getElementsByName("interface"); async function begin(){ if(x[0].checked){ const Easywords = ["Safety", "Steel", "Portal", "Zombie", "Village", "Kitten", "Smoke", "Heaven", "Weapon"] out1.innerHTML = "Easy Mode" for(i = 40; i>=0;i--){ time.innerHTML = i if(i == 0){ out1.innerhtml = "!GAME OVER!" stop } function easyrng(){ const randomIndex = math.floor(math.random() * Easywords.length); const randomword = Easywords[randomIndex]; word.innerHTML = randomword } await sleep(1000) } } else if(x[1].checked){ out1.innerHTML = "Hard Mode" } } function sleep (time) { return new Promise(resolve => setTimeout(resolve, time)); } </script> <div style="text-align: center;"> <input type="button" value="Start!" onclick="begin()"> <br> <input type="text" id="in1"> <input type="button" value="Submit" onclick="submit()"> <input type="radio" name="interface" value="easy" checked>Easy <input type="radio" name="interface" value="hard">Hard </div> </div>
Read Entire Article