JSFiddle - React, Tailwind, and code Playground

HTML

<div id="test">

</div>

CSS

#test{ white-space: prewrap}

JavaScript

// Store the original console.l
const temp = console.log;

// Create an array to hold the commands
const cmds = []

// Overwrite the console.log to store the logs
console.log = (msg) => { cmds.push(msg) };

// Run A
let a = "console.log(\"a\")";
eval(a);

// Run B
let b = "console.log(\"b\")";
eval(b);

// Run C
let c = "console.log(\"c\")";
eval(c);

// Get the logs
let stdout = cmds;

// Revert to orignal console.log
console.log = temp

window.test.innerHTML = stdout.join('\n')