mirror of
https://github.com/TheAlgorithms/JavaScript.git
synced 2025-07-05 16:26:47 +08:00
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:
@ -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
|
||||
|
Reference in New Issue
Block a user