function startGame(){
let currentpoints = 0.01;
var writepoints = document.
getElementById("score").innerHTML = currentpoints += 0.01;
writepoints;
}
This function is called by a button that you press, and its purpose is simple, it
displays currentpoints to an html element by ID after increasing its value.
The code will run with no errors and go up from 0.01 - to 0.02, but it stops there.
it remains 0.02 and does not proceed to go up.
My theory is when the function is called, the declaration of currentpoints is set again to its 0.01 value , but I don't want that, I want it to proceed to go up every time you press the button (call the function), so can someone tell me my remedy to this solution?
Thank you guys, I am a beginner trying to get involved in a way that is fun and rememberable for me. (simple mini game)
New here by the way to stackoverflow.
question from:
https://stackoverflow.com/questions/65932372/function-for-a-value-to-go-up-0-01-when-called-in-javascript-not-working-begin 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…