Update CircularQueue.js for zero-length case (#1655)

* Update CircularQueue.js

* Update CircularQueue.js

Taking comments into account for refactoring my change.

* Update CircularQueue.js

Adding "this" to checkEmpty()
This commit is contained in:
Martin Beacham
2024-04-03 11:25:30 -04:00
committed by GitHub
parent d920e7f427
commit 314144fae6

View File

@ -77,7 +77,7 @@ class CircularQueue {
// Displays the length of queue
length() {
return this.queue.length - 1
return this.checkEmpty() ? 0 : this.queue.length - 1
}
// Display the top most value of queue