Question: The six persons in the queue list are standing in a queue waiting for their turn. Implement the JS code for enqueuing or dequeuing people
The six persons in the queue list are standing in a queue waiting for their turn. Implement the JS code for enqueuing or dequeuing people in the list to simulate the following events:
1. The person at the front of the line (index 0) leaves the line (shift).
2. The person at the end of the line cuts in front of the person at the front of the line (pop and unshift).
3. Two new people named "Tom" and "Snoke" cut into line behind the second person in line (splice).
4. The fifth person in line leaves the line (splice).
5. A new person named "Riddle" enters the back of the line (push).
Finally, display the contents of the line array to view the new line occupants. A correct solution will show: Snape, Dumbledore, Tom, Snoke, null, Weasily, Riddle.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
