-
Notifications
You must be signed in to change notification settings - Fork 0
Towersof hanoi and Loops Project #4
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?
Conversation
| // Your code here | ||
|
|
||
|
|
||
| if (endArray === [4,3,2,1]){ |
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.
This should check for [4,3,2,1] in b or c stack.
|
|
||
| } | ||
| else { | ||
| return "Try again."; |
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.
Your code never runs checkForWin()
|
|
||
| function towersOfHanoi(startStack, endStack) { | ||
| // Your code here | ||
| if (isLegal(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.
Nice concise if statement to check for move legality.
| const startItem = startArray.pop() | ||
| const endItem = endArray.pop() | ||
| if (startItem < endItem){ | ||
| return true; |
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.
Your isLegal fucntion never returns false.
| } | ||
|
|
||
| function isLegal() { | ||
| function getStackArrays(targetStack){ |
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.
This function is a little redundant. For example, on line 24 you could simply run:
startArray = stacks[startStack]
| const targetPiece = startArray.pop() | ||
| endArray.push(targetPiece); | ||
| console.log(targetPiece); | ||
| console.log(endArray) |
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.
Semicolon missing here.
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