Conversation
mmmaaatttttt
left a comment
There was a problem hiding this comment.
@maxnawa31 - thanks for contributing this! minor bookkeeping, mostly around formatting.
In terms of the folder structure, can you rename the folder to problem-solving-evaluate-reverse-polish-notation? I'd generally categorize this as "problem solving" (potentially you could also classify it as a stacks problem, but that's kind of a spoiler for the solution so I'd rather not use the word "stack" in the folder name.)
|
|
||
| Write a method called `evalRPN` that evaluates the value of an arithmetic expression in Reverse Polish Notation. | ||
|
|
||
| Valid operators are +, -, \*, /. Each operand may be an integer or another expression. |
|
|
||
| module.exports = { | ||
| evalRPN | ||
| } No newline at end of file |
| const result = evalRPN(tokens); | ||
| expect(result).toEqual(13); | ||
| }) | ||
| }) No newline at end of file |
| it("Evaluates correctly for ['2', '1', '+', '3', '*']", () => { | ||
| const tokens = ["2", "1", "+", "3", "*"]; | ||
| const result = evalRPN(tokens); | ||
| expect(result).toEqual(9) |
There was a problem hiding this comment.
don't neglect your code formatter! missing semicolon here, also inconsistent use of single vs double quotes etc.
| @@ -0,0 +1,43 @@ | |||
| function evalRPN(tokens) { | |||
There was a problem hiding this comment.
run this file through prettier too.
| if (tokens.length === 1) { | ||
| return parseInt(tokens[0]); | ||
| } | ||
| for (let i = 0; i < tokens.length; i++) { |
There was a problem hiding this comment.
add line break before for loop
|
|
||
| module.exports = { | ||
| evalRPN | ||
| } No newline at end of file |
No description provided.