JSFiddle - React, Tailwind, and code Playground
JavaScript
// Rules state that "input" and "output" functions are not required, but can instead be the variables `s` and `r`.
s = prompt("Enter an equation:", "2+5-6/9*8+7");
function m(x,l,o,r){
return o=='*'?~~r*~~l:~~r/~~l
}
for(M=/(\-?\d+)([\*\/])(\-?\d+)(?=[^\*\/]*$)/;M.test(s);s=s.replace(M,m));
r=eval(s)
alert(r);