fix: repaired number ops

This commit is contained in:
Mike 2023-10-14 07:50:19 -04:00
parent aa4c228502
commit c3e9ec2701

View file

@ -141,16 +141,19 @@ function handleOperatorClick(operatorClicked) {
return;
}
}
ops.operator = operatorClicked;
//TODO fix this conditional should be if numFlag and a check if = or additional ops
if(!ops.onSecondNumber ){
ops.numFlag = true;
} else if (ops.result !== undefined ) {
if (ops.result !== "" ) {
console.log('this is running the ops.result');
ops.firstNum = ops.result;
ops.onSecondNumber = true;
return
}
}
ops.onSecondNumber = !ops.onSecondNumber;
}
@ -185,9 +188,11 @@ function negateNumber(){
function percentageNumber() {
let percent;
if (!ops.numFlag || !ops.onSecondNumber) {
if ((!ops.numFlag || !ops.onSecondNumber) && !ops.result) {
percent = Number(ops.firstNum) / 100;
ops.firstNum = String(percent);
} else if (ops.result !== "" ) {
percent = Number(ops.result) / 100;
} else {
percent = Number(ops.secondNum) / 100;
ops.secondNum = String(percent);