js/calc-model.js
/* Input number can be either number or array, check their type before using them. */
Input number can be either number or array, check their type before using them.
Input number can be either number or array check their type before using them .
function calc(inX, inY, operator) {
    const x = (typeof inX === 'number')? inX : parseFloat(inX.join(''));
    const y = (typeof inY === 'number')? inY : parseFloat(inY.join(''));
    let result = undefined;
    switch (operator) {
        case '+':
            result = add(x, y);
            break;
        case '-':
            result = subtract(x, y);
            break;
        case '*':
            result = multiply(x, y);
            break;
        case '/':
            result = divide(x, y);
            break;
    }
    return result;
}
function calc ( inX , inY , operator ) { const x = ( typeof inX === 'number' ) ? inX : parseFloat ( inX . join ( '' ) ) ; const y = ( typeof inY === 'number' ) ? inY : parseFloat ( inY . join ( '' ) ) ; let result = undefined ; switch ( operator ) { case '+' : result = add ( x , y ) ; break ; case '-' : result = subtract ( x , y ) ; break ; case '*' : result = multiply ( x , y ) ; break ; case '/' : result = divide ( x , y ) ; break ; } return result ; }
Input number can be either number or array, check their type before using them.
Input number can be either number or array check their type before using them .