I have to write code such that when I click a roll dice btn, 5 random numbers get generated and stored in an array and each element is displayed in a diventer image description here
I’ve written this code —
rollDiceBtn.addEventListener("click",() => { for(let i=0;i<5;i++){ diceValuesArr.push(Math.floor(Math.random()*6 + 1)); listOfAllDice[i].textContent = diceValuesArr[i]; } diceValuesArr = []; })
It should work but the IDE is not accepting it.