You are viewing a single comment's thread. Return to all comments →
Hi, I'm using this: function getMax(operations) { const operationsToDo = operations.slice(1); let result = []; let temp = [];
for (let op of operationsToDo) { const [operation, value] = op.split(' ').map(Number); if(operation === 1){ temp.push(value); } else if(operation === 2){ temp.pop(); } else if(operation === 3 && temp.length > 0) { result.push(Math.max(...temp)); } }; return result;
I get an error, do you know why }?
Seems like cookies are disabled on this browser, please enable them to open this website
Maximum Element
You are viewing a single comment's thread. Return to all comments →
Hi, I'm using this: function getMax(operations) { const operationsToDo = operations.slice(1); let result = []; let temp = [];
I get an error, do you know why }?