JSFiddle - React, Tailwind, and code Playground

by smacky311

JavaScript

//As written here the error implies there is a problem on this line
var evalErra = new EvalError('required element missing from evaluation');

var stringFunc = "x=2;y=3;document.write(x*y);";

EvalString(stringFunc);

function EvalString(stringObject) {
    if(stringObject.indexOf('x') !== -1) {
        //throw evalErra;
        throw 'required element missing from evaluation';
    }
    eval(stringFunc);//The problem really lies in the context of this function.
}