In this fourth part of a six-part series on building a web page calculator, we'll delve more deeply into the functions. We start with the operator(ID) function, and then take a closer look at events. We'll wrap up by starting to show how to use the keyboard with the calculator.
Using the Keyboard with a Web Page Calculator (Page 1 of 4 )
Details of the operator(ID) Function
This function uses three global variables. These variables are:
var evalString = ""
//the memory (store) is a variable
var memVar = "";
//after the operation +, -, X and /, the display has to be cleared. We need for this the variable
var toClearDisplay = false;
I talked about these variables before. It suffices here to read the comments. I will come back to the global variables after I explain the operator() function. The operator function has two code segments.