JSFiddle - React, Tailwind, and code Playground

by DariusM

HTML

<!DOCTYPE HTML>
<html>
<head>
  <title>Power</title>
</head>
<body>
  <div>
    <p id='result'></p>
  </div>
</body>
</html>

JavaScript

var equ = "77^7x";
  var base = "77";
  var exp = "7x";
  var output = equ;
  var replace = base + "\\^" + exp;
  var regex = new RegExp("77^7x", "gi");
  var newOutput = output.replace(regex, "Math.pow(" + base + "," + exp + ")");
  document.getElementById('result').innerText = newOutput;
  console.log(newOutput);