Tell us what’s happening:
I successfully completed this challenge. I included some quality checks using console log and there is a quirk. I’m wondering why the console prints:
“Unshifted 3”, instead of “Unshifted 2”?
Your code so far
const s = [5, 7, 2];
function editInPlace() {
// Only change code below this line
let Popped = s.pop();
console.log(s);
console.log("Popped " + Popped);
// Using s = [2, 5, 7] would be invalid
let Unshifted = s.unshift(Popped);
console.log(s);
console.log("Unshifted " + Unshifted);
// Only change code above this line
}
editInPlace();
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36
Challenge: ES6 - Mutate an Array Declared with const
Link to the challenge: