JSFiddle - React, Tailwind, and code Playground

JavaScript

iframeEval = function( code ) {
    var iframe = document.createElement( 'iframe' ),
        script = document.createElement( 'script' );

    iframe.style.display = 'none';
    
    document.body.appendChild( iframe );
    
    iframe.contentWindow.onerror = function (description, url, line) {
        alert("Где возникла ошибка : " + url + "\n\nОшибка на линии : " + line + "\n\nСама ошибка : " + description);
        return true;
    };

    iframe.contentWindow.document.body.appendChild( script );
    script.innerHTML = code;

}

iframeEval("alert('Hello World!');\n\n\n\n      LOL");