Complete the code to add an element to the end of the queue.
queue.[1](5);
In TypeScript arrays used as queues, push adds an element to the end, following FIFO.
Complete the code to remove the first element from the queue.
const first = queue.[1]();The shift method removes the first element from an array, which matches FIFO removal in a queue.
Fix the error in the code to correctly check if the queue is empty.
if (queue.[1] === 0) { console.log('Queue is empty'); }
The length property gives the number of elements in an array. It is not a function, so no parentheses.
Fill both blanks to create a queue from an array and remove the first element.
const queue = [1]; const removed = queue.[2]();
We create a queue as an array [1, 2, 3, 4] and remove the first element using shift().
Fill all three blanks to add an element, remove the first, and check if the queue is empty.
queue.[1](10); const first = queue.[2](); if (queue.[3] === 0) { console.log('Empty now'); }
We add with push, remove with shift, and check emptiness with length.
