- Node >= 12.0
- Browser
cd ./rpn-code-test
node .
> 5 6 9 /
0.66666
Run default test with cases listed at gist:
yarn test
const rpn = require('./rpn-code-test');
rpn.push(5);
const result = rpn.get();
console.log(result); // 5
rpn.clear();
rpn.push("5 6 9 /");
console.log(rpn.get()); // 0.66
- Built a basic CLI implementing an RPN calculator, including optional usage as headless API in Node or in the browser.
- Kept everything as simple and modular as I could.
- If I could do this all again, I'd think about validation more. I wouldn't be surprised if I missed quite a few input scenarios that break this calculator.