Skip to content

Instantly share code, notes, and snippets.

@Luke-Rogerson
Created December 18, 2018 23:08
Show Gist options
  • Select an option

  • Save Luke-Rogerson/dfba86b182e505959cfa34c19144880f to your computer and use it in GitHub Desktop.

Select an option

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
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