You need to set new variables for score and round.
When myFunction()
calculates the result, you would add one to the round variable regardless, and one to the score only if you win.
You would then calculate if the round is greater than ten, in which case you’d call a new function to handle the game over.
It might help to draw a flow diagram before jumping into the JavaScript, as that can help mentally visualise code like this.
edit: from your comment above, is sounds like you need to look into global variables. Declare the variables outside your function, and it won’t reset.
3
solved How to add score to javascript game [closed]