Closed Clund1 closed 9 months ago
There's a problem in this code here:
/Takes tileArrPosition of goblin div and gives it to choice1 or choice 2
//on click of goblin tile store tileArrPosition
goblin.addEventListener('click',(e)=>{
forEach (goblin.e)
//PUSH tileArrPosition into Choice 1 and Choice 2 Variables
let Choice1 = goblin.e.tileArrPosition;
let Choice2 = goblin.e.tileArrPosition;
})
forEach has to be attached to an array, and I'm not sure you want that to happen inside the eventlistener. Grab the goblinEls like you had them before, as a nodelist, so you can run a forEach on them and add the event listener inside the iteration. If you can't get that working, we'll take a look in a 1:1 shortly after deployment party
Fixed the listener but still having errors logging the tileArrPosition ito Choice1 or Choice2
Ok, we can look at this in a 1:1 real shortly!
We resolved this by targeting a specific identifier and saving those to a variable, then checked those values against each other
What's the problem you're trying to solve?
Post any code you think might be relevant (one fenced block per file)
If you see an error message, post it here. If you don't, what unexpected behavior are you seeing?
Im not sure how to organize the event listener to gather the correct information i need
What is your best guess as to the source of the problem?
Genuinely no idea, Tylus ran into trouble helping me as well
What things have you already tried to solve the problem?
MDN, W3 research, tried nesting the eventListener in the initialLaunch function but it gave unpredictable results. Now im trying a forEach to gather the info I need but I cant factor it correctly.
I'm in dire need of a 1 on 1 help meeting.
Paste a link to your repository here[
](https://github.com/Clund1/Project-1---GAME/blob/main/script.js)