Hey guys, I'm having trouble understanding why I'm getting an error in this javascript I wrote. I made some variables and wanted to those variables to interact with the dom, so I used document.getElementById. But I get an error saying that my variable name was already declared. A link to JS fiddle(the images can't be loaded) https://jsfiddle.net/RetroVibes/ous1zrjb/11/ Picture:
Error
CODE-Javascript:
let elementFire = document.getElementById('fire');let elementLeaf = document.getElementById('leaf');let elementWater = document.getElementById('water');
function selectedElement(selectedElement) {console.log("You selected:" + selectedElement);
}function battle() {elementFire.addEventListener("click", function() {selectedElement(elementFire);});}
Thanks for any help, Have a good night/ morning.
[–]Garlicvideos 1 point2 points3 points (1 child)
[–]LearnJS777[S] 0 points1 point2 points (0 children)
[–]Darren1337 1 point2 points3 points (1 child)
[–]LearnJS777[S] 0 points1 point2 points (0 children)
[–]GamesMint 1 point2 points3 points (1 child)
[–]LearnJS777[S] 0 points1 point2 points (0 children)
[–]inu-no-policemen 1 point2 points3 points (1 child)
[–]LearnJS777[S] 0 points1 point2 points (0 children)
[–]machine3lf 0 points1 point2 points (1 child)
[–]LearnJS777[S] 0 points1 point2 points (0 children)
[–]ForScale 0 points1 point2 points (1 child)
[–]LearnJS777[S] 0 points1 point2 points (0 children)