Skip to content

Commit

Permalink
solved reversePolishNotation
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeKarlsson committed Nov 14, 2018
1 parent 55a0dfc commit 3e7c861
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/reversePolishNotation.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ const evalRPN = tokens => {
stack.push(parseInt(result));
}
});
if (stack.length > 1) {
throw new Error("Invalid RPN expression");
}
return stack.pop();
};

Expand Down

0 comments on commit 3e7c861

Please sign in to comment.