js/calc-model.js
/* 
 * Call this function when user press one of the operators[+*-/] button 
 * Main logic:
 *  ==> 1. If has 2 operands, calculate first the result, 
 *  and use it as the first operand of the next operation.
 *  ==> 2. If has only 1 operator, move the cursor forward.
 *  ==> 3. If no operand at all, check the previous result, 
 *  and use it as the first operand of the next operation.
 */
Call this function when user press one of the operators[+*-/] button
Main logic:
==> 1. If has 2 operands, calculate first the result,
and use it as the first operand of the next operation.
==> 2. If has only 1 operator, move the cursor forward.
==> 3. If no operand at all, check the previous result,
and use it as the first operand of the next operation.
Call this function when user press one of the operators [ + * - / ] button Main logic : == > 1 . If has 2 operands calculate first the result and use it as the first operand of the next operation . == > 2 . If has only 1 operator move the cursor forward . == > 3 . If no operand at all check the previous result and use it as the first operand of the next operation .
function operator(operator) {
    if (hasOperands()) {
        if (hasTwoOperands()) {
            data.accumulator = calc(data.operands.shift(), data.operands.shift(), data.operator);
            data.cache = [];
            data.operands[0] = data.accumulator;
            data.cursor = 1;
            data.show = data.accumulator;
        } else {    
            data.cursor = 1;
        }
    } else {        
        data.operands[0] = data.accumulator;
        data.cache = [];
        data.cursor = 1;
    }
    data.operator = operator;
}
function operator ( operator ) { if ( hasOperands ( ) ) { if ( hasTwoOperands ( ) ) { data . accumulator = calc ( data . operands . shift ( ) , data . operands . shift ( ) , data . operator ) ; data . cache = [ ] ; data . operands [ 0 ] = data . accumulator ; data . cursor = 1 ; data . show = data . accumulator ; } else { data . cursor = 1 ; } } else { data . operands [ 0 ] = data . accumulator ; data . cache = [ ] ; data . cursor = 1 ; } data . operator = operator ; }
Call this function when user press one of the operators[+*-/] button
 Main logic:
  ==> 1.
Call this function when user press one of the operators [ + * - / ] button Main logic : == > 1 .
// only has 1 operand // has no operand // updata operator at last