Front Row Seat

Easy+20 XP

Mission Briefing

A Royal VIP has arrived at the grand banquet. You must immediately skip them past the entire waiting line directly to the absolute front of the queue!

The Concept: Array Mutators (Shift/Unshift)

While push and pop handle the end of an array, .unshift() and .shift() handle the beginning:

  • .unshift(val): Squeezes a new value into the front, shifting everything else backward.
  • .shift(): Removes the first value from the front, shifting everything else forward.

The Objective

Your function receives an array queue.

  1. Add the exact string "VIP" to the beginning of the queue array using .unshift().
  2. Return the updated array.

01EXAMPLE 1

Inputqueue = ["Guest1", "Guest2"]
Output["VIP", "Guest1", "Guest2"]

Constraints

  • Use .unshift() for the mission.
FundamentalsArrays
JavaScript
Loading...
3 Hidden

Input Arguments

queue["A","B"]

Expected Output

["VIP","A","B"]

Click RUN to test your solution