mr_larsen — 2011-07-25T18:34:44-04:00 — #1
this.display = "(";
where the variable, display, is what will be displayed in the calculator.
Do you have any suggestions for me, or any source code I could look at? Thanks!
philiptoop — 2011-07-27T06:32:29-04:00 — #2
You are going to have to provide a bit more information.
You have this.display but you talk about a variable display.
A variable is declared by a var statement. for example
this.display is the display property of the this object. But what is "this"?
How all this fits in with you calculator can only be speculated.
mr_larsen — 2011-08-01T14:27:21-04:00 — #3
'this' is only the generic form of the variable, display. In earlier code in my calculator, I declared display as a variable: var display = 0;
Display is initially set as 0 so the calculator starts with a blank screen.
There are actually two variables in this calculator which I have declared: display and total. Both are declared in my code before the actual code I posted.
var display = 0;
var total = 0;
When the user enters a number, this.display (the generic form) is assigned the value of that number. When an operand is hit (+, -, / ...), total is assigned the current value of display, and then display is reset to 0.
Thank you very much for your help!
mr_larsen — 2011-08-01T14:31:36-04:00 — #4
I apologize; I never answered what 'this' is. 'this' is the calculator object (if I understand your question properly. I'm very sorry; I'm a new programmer). The function I initially posted and every other function in the calculator is really a prototype function for the calculator object. So when I use this.display, I'm able to access the variable in any of my prototype functions.
Please let me know if this didn't answer the question you asked. I feel like I hit the ball way into left field.