Skip to content

Commit e62844f

Browse files
authored
Update Queue.js
1 parent 34a8b70 commit e62844f

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

Data-Structures/Queue/Queue.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
// Functions: enqueue, dequeue, peek, view, length
99

10-
const Queue = ( function () {
10+
const Queue = (function () {
1111
// constructor
1212
function Queue () {
1313
// This is the array representation of the queue
@@ -26,7 +26,7 @@ const Queue = ( function () {
2626
throw new Error('Queue is Empty')
2727
}
2828

29-
let result = this.queue[0]
29+
const result = this.queue[0]
3030
this.queue.splice(0, 1) // remove the item at position 0 from the array
3131

3232
return result
@@ -72,9 +72,9 @@ myQueue.enqueue(55)
7272
console.log('Inserted 55')
7373
console.log(`New front item: ${myQueue.peek()}`)
7474

75-
for (let i = 0; i < 5; i ++) {
75+
for (let i = 0; i < 5; i++) {
7676
myQueue.dequeue()
7777
myQueue.view()
7878
}
7979

80-
// console.log(myQueue.dequeue()); // throws exception!
80+
// console.log(myQueue.dequeue()); // throws exception!

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy