I'm currently teaching myself JavaScript and I'm trying to get my loops down. I'm having an issue with += not working while ++ does. It's just something simple but I'm obviously not picking up on it right now. Sorry if this has been asked before, it seems like a simple fix but I just couldn't find it.
var providedNumber = prompt("Please enter a number:");
while (parseInt(providedNumber) <= 20 ) {
document.write("<h3> Counting up " + providedNumber + "</h3>");
providedNumber += 1;
}
I know I have to parseInt() when inputting from a prompt to convert to an integer, do I also need to do that when I am adding or += 1? It works without it if I just use the ++?
" + +providedNumber + "
"` – Jack Bashford Mar 27 '19 at 04:03