const scripts = new Map();
scripts.set("first", "console.log('Here is the first script.')");
scripts.set("second", "console.log('Here is the second.'");
for (var [script_name, code] of scripts) {
try {
eval( code );
} catch(e) {
console.log(`Error occured during execution of "${ script_name }" scripts!`);
}
}
А если у вас класс не добавляется, то опять же - сделайте пример и попробуем посмотреть почему так происходит.