You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

41 lines
572 B
JavaScript

let collection = [];
// Write the queue functions below.
function print() {
return collection;
}
function enqueue(value) {
collection.push(value);
return collection;
}
function dequeue() {
collection.shift();
return collection;
}
function front() {
if (collection.length === 0) {
return undefined;
}
return collection[0];
}
function size() {
return collection.length;
}
function isEmpty() {
return collection.length === 0;
}
module.exports = {
print,
enqueue,
dequeue,
front,
size,
isEmpty
};