You are viewing a single comment's thread. Return to all comments →
Hi! Do you have any idea why my code can't pass all cases? I would appreciate any help. Btw, the peek and pop function comes from a stack class.
function processData(input) { for (let i = 0; i < input.length; i++) { let op = input[i].slice(0, 1) let strg = input[i].slice(1).trim() if (op == '1') { s+=strg lastStr.push(s) } else if (op == '2') { s=s.slice(0,-strg) lastStr.push(s) lastOpType = 2 } else if (op == '3') { if(s.length>=1){ console.log(s[strg - 1]) } } else if (op == '4') { lastStr.pop() s=lastStr.peek() } } }
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 →
Hi! Do you have any idea why my code can't pass all cases? I would appreciate any help. Btw, the peek and pop function comes from a stack class.