How do I continuously add a value to a variable?


#1

I'm making a riddle game for a school project, and its basically having the computer prompt you for answers, and if the answer is correct, you get a point. I want to do it so that when you get the question right, 1 gets added to the variable userScore which is the points that the user has.

var userScore = 0
var userAnswer = prompt("a or b")
if (userAnswer === "b") {
userScore + 1
};

sort of like this, so how do i get the score to increase and keep its value after the question?


#2

userScore += 1 :slightly_smiling:


#4

Thank you very much!