Challenge: Practicing `pop` & `shift`
Task
Swipe to start coding
- Use the
popmethod to remove the last element of theitemsarray. - Use a
console.logstatement to print the array after usingpop, in the format:After pop: [ element1, element2, ... ]. - Use the
shiftmethod to remove the first element of the array. - Use a
console.logstatement to print the array after usingshift, in the format:After shift: [ element1, element2, ... ].
Note
The
pop()method should be used before using theshift()method.
Solution
Everything was clear?
Thanks for your feedback!
Section 1. Chapter 62
single
Ask AI
Ask AI
Ask anything or try one of the suggested questions to begin our chat
Awesome!
Completion rate improved to 1.33
Challenge: Practicing `pop` & `shift`
Swipe to show menu
Task
Swipe to start coding
- Use the
popmethod to remove the last element of theitemsarray. - Use a
console.logstatement to print the array after usingpop, in the format:After pop: [ element1, element2, ... ]. - Use the
shiftmethod to remove the first element of the array. - Use a
console.logstatement to print the array after usingshift, in the format:After shift: [ element1, element2, ... ].
Note
The
pop()method should be used before using theshift()method.
Solution
Everything was clear?
Thanks for your feedback!
Section 1. Chapter 62
single