The last clause of the instructions just confused the heck out of me

Tell us what’s happening:

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()

Link to the challenge:

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"]

1 Like

that explains what i already know.
thats seems to be what you do.

thanks anyway.

if your question was “Why the variables are put in an array?”, that’s just what the challenge asks for

Otherwise, please ask again

I believe I was confused by the order it returned. Maybe my last line was confusing? I cannot review or revise now can I. Thanks.


I see now that its the way the return statement was written. My forum option is gone. Please just let it die.


@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.

did you just want to be condescending one more time? I know my signature is there I don’t care if you know who I am. I asked you to let it go.


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?

I have closed this thread, as the conversation appears to be going off-topic, and the original query has been addressed.

Feel free to open a new topic, with the intention to continue fruitful discussion :smiley: