JSFiddle - React, Tailwind, and code Playground

by Andreas Renberg

JavaScript

function m(x,l,o,r){L=parseInt(l);R=parseInt(r);switch(o){case '*':return R*L;case '\/':return R/L;}};s=prompt();M=/(\-?\d+)([\*\/])(\-?\d+)(?=[^\*\/]*$)/;while(M.test(s)){s=s.replace(M,m)};alert(eval(s))