JSFiddle - React, Tailwind, and code Playground

HTML

<textarea name="" id="" cols="30" rows="10">
    var b ="instance of a variable , c current value is: ";
    c++;
    console.log(a, b , c);
</textarea>
<br>
<button id="boom">EXECUTE!</button>

JavaScript

//THIS IS SOME DEMO VARIABLE TO SHOW
var a = "this will show in the console ";
var c = 1;
jQuery(document).ready(function($){
    $("#boom").click(function(e){
        var thecode =$("textarea").text();
        
        var s = document.createElement("script");
        s.type = "text/javascript";
        s.id = "codetoexecute";
        s.innerHTML = thecode;
        $("head").remove("#codetoexecute");
        
        $("head").append(s);
        e.preventDefault();
    });
});