assign the removed elements to their corresponding variables,
so that the returned array contains their values.`
so why would pop and shift put them into an array and why would they be in that order? wouldnt it have returned complete challenge?
Your code so far
function popShift(arr) {
let popped = arr.pop(); // Change this line
let shifted = arr.shift(); // Change this line
return [shifted, popped];
}
console.log(popShift(['challenge', 'is', 'not', 'complete']));
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36.
Challenge: Remove Items from an Array with pop() and shift()
you are asked to return the elements removed by pop and shift, pop and shift do not put elements in array, that’s done using the shifted and popped variables
pop removes the last element, shift removes the first element of the array
which are "complete" and "challenge" respectively, putting first the shiftend and then the popped variable, you get ["challenge", "complete"]
@thegirlyoucallryan You may want to remove the email signature from your posts. Just letting you know so you don’t give out information you maybe didn’t intend to.
I was just letting you know that your posts had personal information to make sure you didn’t give out information on a public forum that you didn’t intend to give out.
How is that condescending? And what do you mean by one more time?