My if
statements don't work because I said to the statements to make subtract, if subtractOp
(subtract button is clicked) were click and this operator still doing add function.
let firstValue;
let secondValue;
addOp.addEventListener('click', function() {
firstValue = Number(outPut.innerText);
outPut.innerText = '';
});
subtractOp.addEventListener('click', function() {
firstValue = Number(outPut.innerText);
outPut.innerText = '';
});
multiplyOp.addEventListener('click', function() {
firstValue = Number(outPut.innerText);
outPut.innerText = '';
});
equals.addEventListener('click', function() {
secondValue = Number(outPut.innerText);
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));
}
});
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…