Permalink
Browse files

Refactored slightly, more 'correct' javascript.

  • Loading branch information...
1 parent 6e8adcf commit 1e563e955bcb7992357e75c73b7e3d399cbd8f23 @matholroyd committed Mar 4, 2012
Showing with 5 additions and 4 deletions.
  1. +5 −4 javascript/lyahfgg/chapter-10.js
@@ -16,13 +16,14 @@ exports.solveRPN = function(equation) {
}
var terms = equation.trim().split(/\s+/),
- stack = [];
+ stack = [],
+ a, b, op;
_und.each(terms, function(t) {
if(get_operator(t)) {
- var b = stack.pop(),
- a = stack.pop(),
- op = get_operator(t);
+ b = stack.pop();
+ a = stack.pop();
+ op = get_operator(t);
stack.push(op(a, b));
} else {
stack.push(parseFloat(t))

0 comments on commit 1e563e9

Please sign in to comment.