Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 29 additions & 6 deletions src/queue/queue-data-structure.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,47 @@ class Queue {
}

canEnqueue() {
// ... your code goes here
if (this.queueControl.length < this.MAX_SIZE) {
return true
} else {
return false
}

}


isEmpty() {
// ... your code goes here
if (this.queueControl.length === 0) {
return true
} else {
return false
}


}

enqueue(item) {
// ... your code goes here
if (this.canEnqueue() === true) {
this.queueControl.push(item)
return this.queueControl
} else {
throw new Error('QUEUE_OVERFLOW');
}

}

dequeue() {
// ... your code goes here
if (!this.isEmpty()) {
return this.queueControl.shift()
} else {
throw new Error('QUEUE_UNDERFLOW')
}

}

display() {
// ... your code goes here
}
return this.queueControl
}
}

// This is required to enable the automated tests, please ignore it.
Expand Down
12 changes: 1 addition & 11 deletions src/queue/queue-dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,4 @@ const addToQueue = () => {
// there was an overflow error, handle it
}
};

const removeFromQueue = () => {
try {
// ... your code goes here
} catch (error) {
// there was an underflow error, handle it
}
};

addQueue.addEventListener('click', addToQueue);
dequeue.addEventListener('click', removeFromQueue);
https://github.com/ironhack-labs/lab-js-chronometer/pull/677
37 changes: 31 additions & 6 deletions src/stack/stack-data-structure.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,50 @@ class Stack {
}

canPush() {
// ... your code goes here
if (this.stackControl.length < this.MAX_SIZE) {
return true
} else {
return false
}

}

isEmpty() {
// ... your code goes here
if (this.stackControl.length === 0) {
return true
} else {
return false
}

}

push(item) {
// ... your code goes here
if (this.canPush() === true) {
this.stackControl.push(item)
return this.stackControl
} else {
throw new Error('STACK_OVERFLOW');
}

}

pop() {
// ... your code goes here
if (!this.isEmpty()) {
return this.stackControl.pop()
} else {
throw new Error('STACK_UNDERFLOW')
}


}

display() {
// ... your code goes here
}
return this.stackControl
}
}

// This is required to enable the automated tests, please ignore it.
if (typeof module !== 'undefined') module.exports = Stack;