From c3e9ec270180d387624d7d63c960b13165a84f12 Mon Sep 17 00:00:00 2001 From: Smig Tech Date: Sat, 14 Oct 2023 07:50:19 -0400 Subject: [PATCH 1/2] fix: repaired number ops --- calculator/js/script.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/calculator/js/script.js b/calculator/js/script.js index 9e6c1ec..4898482 100644 --- a/calculator/js/script.js +++ b/calculator/js/script.js @@ -141,15 +141,18 @@ 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 ) { - console.log('this is running the ops.result'); - ops.firstNum = ops.result; - ops.onSecondNumber = true; - return + 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); From 56e3af699c126fe4b24551d2a8db885805ac6204 Mon Sep 17 00:00:00 2001 From: Smig Tech Date: Sat, 14 Oct 2023 07:51:26 -0400 Subject: [PATCH 2/2] fix: repaired number ops --- calculator/js/script.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/calculator/js/script.js b/calculator/js/script.js index 4898482..3c37b9a 100644 --- a/calculator/js/script.js +++ b/calculator/js/script.js @@ -188,7 +188,7 @@ function negateNumber(){ function percentageNumber() { let percent; - if ((!ops.numFlag || !ops.onSecondNumber) && !ops.result) { + if ((!ops.numFlag || !ops.onSecondNumber)) { percent = Number(ops.firstNum) / 100; ops.firstNum = String(percent); } else if (ops.result !== "" ) {