-
Notifications
You must be signed in to change notification settings - Fork 0
checkpoint1 #8
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
base: gh-pages
Are you sure you want to change the base?
checkpoint1 #8
Conversation
reneemeyer
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job, just some function organization changes. Overall though, great methods
|
|
||
| function movePiece(startStack, endStack) { | ||
| if (startStack === 'a' && endStack === 'b') { | ||
| let mover = stacks.a.pop(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be const
| // Your code here | ||
|
|
||
| function movePiece(startStack, endStack) { | ||
| if (startStack === 'a' && endStack === 'b') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for every stack and letter, you're checking if the stack is a,b, or c, twice, that's a lot of repetition that you can condense.
| let mover = stacks.a.pop(); | ||
| stacks.b.push(mover); | ||
| } else if (startStack === 'a' && endStack === 'c') { | ||
| let mover = stacks.a.pop(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be const
| let mover = stacks.a.pop(); | ||
| stacks.c.push(mover); | ||
| } else if (startStack === 'b' && endStack === 'a') { | ||
| let mover = stacks.b.pop(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be const
| let mover = stacks.b.pop(); | ||
| stacks.a.push(mover); | ||
| } else if (startStack === 'b' && endStack === 'c') { | ||
| let mover = stacks.b.pop(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be const
| let mover = stacks.b.pop(); | ||
| stacks.c.push(mover); | ||
| } else if (startStack === 'c' && endStack === 'a') { | ||
| let mover = stacks.c.pop(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be const
| let mover = stacks.c.pop(); | ||
| stacks.a.push(mover); | ||
| } else { | ||
| let mover = stacks.c.pop(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be const
| function isLegal(start, end) { | ||
| const startStack = stacks[start]; | ||
| const endStack = stacks[end]; | ||
| if (startStack.length === 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
anytime that you see that you're returning true or false, return the evaluation
|
|
||
| function checkForWin() { | ||
| // Your code here | ||
| if (stacks.b.length === 4 || stacks.c.length === 4) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
anytime that you see that you're returning true or false, return the evaluation
| function towersOfHanoi(startStack, endStack) { | ||
| // Your code here | ||
|
|
||
| movePiece(startStack, endStack); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you should only move the piece if your function is legal, and you should only check for win if your function is legal
Checkpoint Rubric
This is the rubric that your instructor will use to grade your checkpoints. Please do not edit.
Checkpoint 1
Checkpoint 2
Checkpoint 3