diff --git a/Data Structures/queueClass.js b/Data Structures/queueClass.js new file mode 100644 index 0000000..f408ca2 --- /dev/null +++ b/Data Structures/queueClass.js @@ -0,0 +1,25 @@ +// https://www.freecodecamp.org/learn/coding-interview-prep/data-structures/create-a-queue-class + +function Queue() { + var collection = []; + this.print = function () { + console.log(collection); + }; + // Only change code below this line + this.enqueue = function (elem) { + collection.push(elem); + }; + this.dequeue = function () { + return collection.shift(); + }; + this.front = function () { + return collection[0]; + }; + this.size = function () { + return collection.length; + }; + this.isEmpty = function () { + return !collection.length; + }; + // Only change code above this line +}