|
@@ -53,8 +53,7 @@ function Subtraction() {
|
|
|
let carryArrCopy = [...carryArr];
|
|
|
carryArrCopy.unshift(e.target.value);
|
|
|
setCarryArr(carryArrCopy);
|
|
|
-
|
|
|
- let noCarry = carryArrCopy[0] === "0" || carryArrCopy[0] === undefined;
|
|
|
+ let noCarry = carryArrCopy[0] === "" || carryArrCopy[0] === "0" || carryArrCopy[0] === undefined;
|
|
|
if((nosLeft === 1 && noCarry) ||
|
|
|
|
|
|
(nosLeft !== nosLeft && realResult.toString().length === 1 && noCarry)){
|
|
@@ -63,7 +62,7 @@ function Subtraction() {
|
|
|
}
|
|
|
|
|
|
if(nosLeft === 0){
|
|
|
- createIdmtResults()
|
|
|
+ createIdmtResults(carryArrCopy)
|
|
|
setShowAlert(true);
|
|
|
}
|
|
|
}
|
|
@@ -219,13 +218,13 @@ function Subtraction() {
|
|
|
addButtonsToImdtSteps();
|
|
|
}
|
|
|
|
|
|
- const createIdmtResults = () => {
|
|
|
+ const createIdmtResults = (carryArrCopy) => {
|
|
|
let realResArr = realResult.toString().split("");
|
|
|
while(realResArr.length < resArr.length){
|
|
|
realResArr.unshift(" ");
|
|
|
}
|
|
|
|
|
|
- let carries = carryArr.map(x => x || "0")
|
|
|
+ let carries = carryArrCopy.map(x => x || "0")
|
|
|
carries.push("0");
|
|
|
while(carries.length < resArr.length){
|
|
|
carries.unshift("0");
|