+ 1

Help me!!

function win(userChoice, compChoice) { userScore++; console.log("WIN"); console.log(userScore); userScore_span.innerHTML = userScore; compScore_span.innerHTML = compScore; result_p.innerHTML = ... how can solve this?? it tells me its "an error in syntax innerHTML"

2nd Aug 2020, 7:52 AM
GhostRecon
GhostRecon - avatar
2 Respuestas
+ 3
userScore_span is like a variable it's not pointing to DOM that what I can see from this code. You need to point to DOM element that you want to change inner HTML like this. document.getElementById("id_name_of_element").innerHTML = userScore
2nd Aug 2020, 7:59 AM
Maninder $ingh
Maninder $ingh - avatar
+ 1
var userScore_span = document.getElementById("userScore").innerHTML = userScore; var compScore_span = document.getElementById("compScore").innerHTML = compScore; its the same result’s
2nd Aug 2020, 8:08 AM
GhostRecon
GhostRecon - avatar