Skip to content

Commit

Permalink
🐛 fix: error when expression starts with digit
Browse files Browse the repository at this point in the history
  • Loading branch information
Leslie-Wong-H committed Oct 13, 2021
1 parent 92d1684 commit 43c374f
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion jsbi-calculator.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,15 @@ function arrayizeExpression(expression) {
acc[acc.length - 2] === "("
) {
acc[acc.length - 1] += newCur;
// newCur(digit) next to symbols
} else if (checkArray.indexOf(acc[acc.length - 1]) > -1 && newCur) {
acc.push(newCur);
} else {
// newCur(digit) next to digit
} else if (acc.length !== 0 && acc[acc.length -1]) {
acc[acc.length - 1] += newCur;
// newCur(digit) in the front of the expression
} else {
acc.push(newCur);
}
}
return acc;
Expand Down

0 comments on commit 43c374f

Please sign in to comment.