JSFiddle - React, Tailwind, and code Playground

by mrnobody

HTML

<input id="formula"><input type="button" value="=" onClick="go()">
<span id="otvet"></span>

JavaScript

function go()
{
	var formula = document.getElementById('formula').value;
  console.log(eval(formula))
  //document.getElementById('otvet').innerHTML = eval(formula);
  var func = new Function('formula', 'document.getElementById(\'otvet\').innerHTML = formula');
  func(formula);
}