mirror of
https://gitea.smigz.com/smiggiddy/odin-codeprojects.git
synced 2024-12-26 06:20:42 -05:00
fix: corrected additional add issue
This commit is contained in:
parent
abb1370a11
commit
aa4c228502
1 changed files with 10 additions and 8 deletions
|
@ -93,14 +93,11 @@ function handleOperation() {
|
||||||
ops.result = result;
|
ops.result = result;
|
||||||
|
|
||||||
if (ops.lastOperator === '=') {
|
if (ops.lastOperator === '=') {
|
||||||
console.log('This ran');
|
|
||||||
ops.firstNum = String();
|
ops.firstNum = String();
|
||||||
ops.secondNum = String();
|
ops.secondNum = String();
|
||||||
ops.numFlag = false;
|
ops.numFlag = false;
|
||||||
ops.onSecondNumber = !ops.onSecondNumber;
|
ops.onSecondNumber = !ops.onSecondNumber;
|
||||||
console.log(`Changing second number ${ops.onSecondNumber}`);
|
|
||||||
} else {
|
} else {
|
||||||
console.log("this else ran");
|
|
||||||
ops.firstNum = ops.result;
|
ops.firstNum = ops.result;
|
||||||
ops.secondNum = "";
|
ops.secondNum = "";
|
||||||
ops.onSecondNumber = true;
|
ops.onSecondNumber = true;
|
||||||
|
@ -134,21 +131,26 @@ function handleOperatorClick(operatorClicked) {
|
||||||
return;
|
return;
|
||||||
} else if (operatorClicked === '+/-') {
|
} else if (operatorClicked === '+/-') {
|
||||||
negateNumber();
|
negateNumber();
|
||||||
return
|
return;
|
||||||
} else if (operatorClicked === '%') {
|
} else if (operatorClicked === '%') {
|
||||||
percentageNumber();
|
percentageNumber();
|
||||||
return
|
return;
|
||||||
} else {
|
} else {
|
||||||
if(ops.secondNum && ops.numFlag){
|
if(ops.secondNum && ops.numFlag){
|
||||||
handleOperation();
|
handleOperation();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ops.operator = operatorClicked;
|
ops.operator = operatorClicked;
|
||||||
//TODO fix this conditional should be if numFlag and a check if = or additional ops
|
//TODO fix this conditional should be if numFlag and a check if = or additional ops
|
||||||
if(!ops.onSecondNumber){
|
if(!ops.onSecondNumber ){
|
||||||
ops.numFlag = true;
|
ops.numFlag = true;
|
||||||
}
|
} else if (ops.result !== undefined ) {
|
||||||
|
console.log('this is running the ops.result');
|
||||||
|
ops.firstNum = ops.result;
|
||||||
|
ops.onSecondNumber = true;
|
||||||
|
return
|
||||||
|
}
|
||||||
ops.onSecondNumber = !ops.onSecondNumber;
|
ops.onSecondNumber = !ops.onSecondNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue