Code: http://pastebin.com/xGa9VLDY
The question:
I am making a little calculator app to hone my JavaScript skills, and it turned out alright. However, the problem I am experiencing is that JavaScript returns my variable 'memory' as 0, even though the value is increased (or decreased), and I can't seem to figure out how, so the calculator is pretty much useless, since the equal button only returns 0. I've tried to use the console in Chrome to increase the value, just to test and this is my result:
memory + 5
5
But when I try to check the value of 'memory' again:
memory
0
Is it something I am missing, or is it just a stupid, little mistake?
What I've tried:
As you can see, I have now tried to store the value in localStorage, but to no avail, and I do not see what else I can do. I recently switched from
memory += textBox.value;
to
memory = memory + textBox.value;
but obviously, that didn't work either.
EDIT:
I have got a very strange problem now:
memory: 0
textBox.value: "6"
parseInt(textBox.value): 6
memory + parseInt(textBox.value): 6
typeof(memory): "number"
This is all the values when the textbox still is populated with a number, and this is these are values right after pressing the plus sign:
memory: NaN
textBox.value: ""
parseInt(textBox.value): NaN
memory + parseInt(textBox.value): NaN
typeof(memory): "number"