Prefix Notation Evaluation

Published by BijogFc24 in

Create a function that takes a mathematical expression in prefix notation as a string and evaluates the expression.

Examples

prefix("+ 5 4") ➞  9

prefix("* 12 2") ➞  24

prefix("+ -10 10") ➞  0

Notes

  • The mathematical expression is valid.
  • Check the Resources.
  • Use // for division.
Watch a quick demo on how Edabit works.