You are viewing a single comment's thread. Return to all comments →
JS
function processData(input) { const undo = [""]; const operations = [ (append) => undo.push(undo.at(-1) + append), (_delete) => undo.push(undo.at(-1).slice(0, undo.at(-1).length - _delete)), (print) => console.log(undo.at(-1).at(print - 1)), () => undo.pop() ]; input.split("\n").slice(1).forEach((operation) => operations[operation.split(" ")[0] - 1](operation.split(" ")[1])); }
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 →
JS