Adding solution for queue class (#36319)

This commit is contained in:
Prashanth Ashok Ramkumar
2019-07-02 10:45:42 -04:00
committed by Randell Dawson
parent d118e199c5
commit b68f752847

View File

@ -68,6 +68,32 @@ function Queue() {
<section id='solution'> <section id='solution'>
```js ```js
// solution required function Queue () {
var collection = [];
this.print = function() {
console.log(collection);
};
// Only change code below this line
this.enqueue = function(item) {
collection.push(item);
}
this.dequeue = function() {
return collection.shift();
}
this.front = function() {
return collection[0];
}
this.size = function(){
return collection.length;
}
this.isEmpty = function() {
return collection.length === 0 ? true : false;
}
// Only change code above this line
}
``` ```
</section> </section>