You are viewing a single comment's thread. Return to all comments →
JavaScript (NodeJS) Solution
let result = ""; const history = [""]; function processCommand(input) { const [command, option] = input.split(" "); switch (command) { case "1": result += option; history.push(result); break; case "2": result = result.slice(0, result.length - option); history.push(result); break; case "3": console.log(result[option - 1]); break; case "4": history.pop(); result = history.at(-1); break; default: break; } } function processData(input) { input.split(/\r?\n/).slice(1).forEach(processCommand); }
Seems like cookies are disabled on this browser, please enable them to open this website
Simple Text Editor
You are viewing a single comment's thread. Return to all comments →
JavaScript (NodeJS) Solution