Created
December 18, 2018 23:08
-
-
Save Luke-Rogerson/dfba86b182e505959cfa34c19144880f to your computer and use it in GitHub Desktop.
Create a queue data structure. The queue should be a class with methods 'add' and 'remove'. Adding to the queue should store an element until it is removed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Queue { | |
| constructor() { | |
| this.data = []; | |
| } | |
| add(n) { | |
| this.data.unshift(n); | |
| } | |
| remove() { | |
| return this.data.pop(); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment