I know it’s simple using index to assign new variable, but I want to try another way using pop and push method. can someone please fix the code so It can work as well for this challenge?
Your code so far
const s = [5, 7, 2];
function editInPlace() {
// i want to use .pop and .push for this challenge. please help
const delLast = s.pop();
return s.push(2);
// or can it be ?
// return s.pop().push(2) ?
}
editInPlace();
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36