function myFunction(){
var gold = 0;
function addGold(){
gold++;
}
addGold();
document.getElementById("body").innerHTML = "gold is " + gold;
}
window.setInterval(myFunction,1000);
I'm pretty sure that the addGold function won't change the gold variable.
You should replace "return gold + 1;" with "gold = gold ++;" (which is the same as gold = gold + 1)
Comments
Viewing 21 through 26 of 26 comments