Tell us what’s happening:
Okay, so I’m working on the dice game, and I’m trying to test the dice rolls though VSCode as well, but it keeps throwing the following error:
Uncaught TypeError: listOfAllDice.forEach is not a function
at rollDice (dice-game.js:29:17)
at HTMLButtonElement.<anonymous> (dice-game.js:96:5)
Any advice? Thanks.
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36
Challenge Information:
Review Algorithmic Thinking by Building a Dice Game - Step 7
this type of error is exactly what it says it is, a Type Error.
Which means that the type of listOfAllDice is not compatible with the function forEach that you are trying to apply to it.
You can investigate this yourself by reading the code to see what type of thing listOfAllDice is (and possibly by googling a bit) and then comparing that type with the type of thing that forEach works with. (if they are not the same or compatible then you need to take an extra step to match these two types up, like a jigsaw puzzle that is missing a piece in the middle to finish it)
let me know if I’ve given you enough hints…
Okay, I figured it out.
I looked over my code in the editor and realized that the variable was not declared properly–I had used .querySelector instead of .querySelectorAll.
Once i changed it, everything started to work.
Thanks! 
2 Likes