-
Notifications
You must be signed in to change notification settings - Fork 0
checkpoint 1 #6
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?
checkpoint 1 #6
Conversation
|
I know this doesn't exactly work I tried my best |
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.
nice job, see comments below
| function checkForWin() { | ||
| // Your code here | ||
| const isLegal = (startStack, endStack) => { | ||
| const SSLastNum = stacks[startStack][stacks[startStack].length-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.
These variable names should start with a lowercase letter. The convention is upper case would signify a class.
| const SSLastNum = stacks[startStack][stacks[startStack].length-1]; | ||
| const ESLastnum = stacks[endStack][stacks[endStack].length-1]; | ||
| if (ESLastnum > SSLastNum) { | ||
| 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.
this can be simplified, just return the evalutation
|
|
||
| } | ||
| const checkForWin = () => { | ||
| let checkWin = false; |
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 would always return a truthy value ('You win' or 'You suck') so your parent function that checks for the return would always reset the stack. What would be better is if you just returned a truthy or falsy value and have the parent function return the message.
| const checkForWin = () => { | ||
| let checkWin = false; | ||
| const solution = [4, 3, 2, 1]; | ||
| for (index = 0; index < 4; index++) { |
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 loop is unnecessary, just check if stack b or c has a length of 4
| function towersOfHanoi(startStack, endStack) { | ||
| // Your code here | ||
| const resetStack = () => { | ||
| let stacks = { |
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 shouldn't redeclare here, stacks were defined at line 22
| if (stacks[endStack].length == 0) { | ||
| movePiece(startStack, endStack); | ||
| } else { | ||
| 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.
good function organization
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