Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C16 - Cedar - Afina Walton #1

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
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
14 changes: 9 additions & 5 deletions lib/stack.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
const LinkedList = require("./linked-list");

class Stack {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👀 While your implementation does work and utilize Javascript arrays effectively, unfortunately the readme requested you implement stacks using the included LinkedList class.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

constructor() {
this.store = []
this.store = new LinkedList();
}

push(element) {
this.store.push(element);
this.store.addLast(element);
return;
}

pop() {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return this.store.pop();
const toRemove = this.store.getLast();
this.store.delete(toRemove);

return toRemove;
}

isEmpty() {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (!this.store.length) return true;
return false;
return this.store.isEmpty();
}

toString() {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👀 You might consider LinkedList's toString method instead!

Expand Down