Evaluates well-formed reverse polish notation expressions (http://en.wikipedia.org/wiki/Reverse_Polish_notation).
Strings with tokens separated by single spaces. Tokens are operators or operands. Operators are +, -, * or /. Operands are integers or floats (e.g. 7, 3.23, -1e9).
The value of the evaluated expression.
"1 1 +" -> 2
"5 8 -" -> -3
"2 3 7 + -" -> -8
"5 3 * 5 +" -> 20
With ES6 you can
d
variable to the top so you can ignore one(, )
With the use of
=>
function you can also remove allreturn
and make one liner by omitting{}
that makes it return the first thing