Try this:
<!DOCTYPE html>
<html>
<body>
<input type="text" id="jssyntax" placeholder="type js here" value="">
<button onclick="myFunction()">Run it</button>
<script>
function myFunction() {
var syntax = document.getElementById("jssyntax").value;
eval(syntax);
}
</script>
</body>
</html>