That's because your if/else statement in the equals handler is wrong.
if(addOp) {
outPut.innerText = add(firstValue, secondValue);
console.log(add(firstValue, secondValue));
} else if(subtractOp) {
outPut.innerText = subtract(firstValue, secondValue);
console.log(subtract(firstValue, secondValue));
} else if(multiplyOp) {
outPut.innerText = multiply(firstValue, secondValue);
console.log(multiply(firstValue, secondValue));
}
if(addOp)
always returns true because addOp
is an HTML element. You need to add booleans to determine what operation you wish to perform.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…