April 2018
Beginner to intermediate
426 pages
10h 19m
English
Now, let's implement some additional helper methods for our class. If we want to know what the front element of our queue is, we can use the peek method. This method will return the item from the front of the queue (using the lowestCount as a key to retrieve the element value):
peek() { if (this.isEmpty()) { return undefined; } return this.items[this.lowestCount];}