shradha-khapra / JavaScriptSeries

247 stars 210 forks source link

issue in rock paper scissors game. #22

Open JAXSH3 opened 4 months ago

JAXSH3 commented 4 months ago

when i was making this project on my system then one issue occurred which was in JavaScript. "choices.forEach((choice) => { choice.addEventListener("click", () => { const userChoice = choice.getAttribute("id"); playGame(userChoice); }); });" in this part of code browser was not showing id name it was returning null value. i have checked my html and JavaScript code but the naming was proper everything else worked fine just this one issue that the id names are not showing just the null value is returning ![isssue1](https://github.com/shradha-khapra/JavaScriptSeries/assets/95120225/283baaf9-53bb-4c83-aae7-3b80312dab86) ![issueHTML](https://github.com/shradha-khapra/JavaScriptSeries/assets/95120225/f1983fe1-ac73-45e7-a27c-87105ec060da) ![issueJS](https://github.com/shradha-khapra/JavaScriptSeries/assets/95120225/900b87c3-708d-44de-81a7-f6986e84a83e)

Shreekant-04 commented 4 months ago

check if you are using id properly.

JAXSH3 commented 4 months ago

check if you are using id properly.

yeah got it. it was silly error in html code i gave id to img tag rather than the the div the image was in. that's the reason console was returning null value. thank you for your help.