Research the .push() function and look at what it returns (hint: your statement above was incorrect. It is not “nothing”.)
The line remove.shift();
will only work if remove
is an array.
Research the .push() function and look at what it returns (hint: your statement above was incorrect. It is not “nothing”.)
The line remove.shift();
will only work if remove
is an array.
remove will contain the length of the array.
You cannot use return remove.shift();
You should use return arr.shift();
Thanks for not just spitting out the answer. I had the same problem. Thinking through the parts you highlighted was a big help.
I’m glad I could help. Happy coding!
This had me stumped also for a hot minute.
The .shift function removes the first item from array and returns the new length of that array, so returning it won’t give you the value you are seeking. The reason you are getting the error in console.log is because the item you are performing the method on is not an array.