-
Notifications
You must be signed in to change notification settings - Fork 0
Checkpoint1 towers #9
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
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.
Eric, your logic is good and it seems like you're planning out where you want to go in your code. However, we just need to refine your follow through and methods. Make sure every step of the way you are testing your code. Don't assume that your function works, that's how you miss a lot of small bugs that make your app fail.
03week/towersOfHanoi.js
Outdated
| function towersOfHanoi(startStack, endStack) { | ||
| // Your code here | ||
|
|
||
| isLegal |
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 is calling a variable not a function.
| // Your code here | ||
|
|
||
| isLegal | ||
| } |
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.
I see where you are going with this, however, in functional programing you want to have each function have a specific and containable purpose. So isLegal()'s only job is to check if the move is legal, then if the return of that function is legal, then you would call your move function.
03week/towersOfHanoi.js
Outdated
|
|
||
| //checkForWin, if all of the numbers are in the last stack, run the win sequence, which should reset the object, if statement | ||
| const checkForWin=()=> | ||
| if (stacks === [a: [], b: [1], c:[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.
I like where your'e going here, however in Javascript, you can't directly compare two objects or arrays. The reason being is that every object is different. So if you made an object const a ={} and const b = {}, Javascript will never evaluate a === b. So knowing that, what is a different way that you could check for a win?
03week/towersOfHanoi.js
Outdated
|
|
||
| //isLegal(), checks to see if the last index of the start stack is less than the end stack last index. If the value is less, run movePiece. If the value is greater, deny the move, lastindexof method | ||
| const isLegal=(startstack, endStack)=> { | ||
| if((startstack.lastindexof < endStack.lastindexof) || (startstack.lastindexof > 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.
lastIndexOf is being called incorrectly. It's a method, so you need to call it as a function and give it at least one argument. Please consult the docs https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/lastIndexOf
03week/towersOfHanoi.js
Outdated
| }; | ||
| //movePiece(), Moves the last index of the startStack to the last index of the endStack, lastindexof method | ||
| const movePiece=(startstack, endStack)=> { | ||
| endStack.push(startstack.lastindexof) |
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.
lastIndexOf is being called incorrectly. It's a method, so you need to call it as a function and give it at least one argument. Please consult the docs https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/lastIndexOf
03week/towersOfHanoi.js
Outdated
| //movePiece(), Moves the last index of the startStack to the last index of the endStack, lastindexof method | ||
| const movePiece=(startstack, endStack)=> { | ||
| endStack.push(startstack.lastindexof) | ||
| startstack.lastindexof.slice |
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.
I see that you're trying to chain methods here, and what you're trying to do, however slice and lastindexOf are being called incorrectly.
03week/towersOfHanoi.js
Outdated
| function movePiece() { | ||
| // Your code here | ||
| //printBeginningStacks, reset the var stacks to its original position, nest stacks inside | ||
| const printBeginningStacks=(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.
Not sure what this function does.
03week/towersOfHanoi.js
Outdated
|
|
||
| function printStacks() { | ||
| //This function prints the stacks on to the screen. Part of premade code | ||
| let printStacks() { |
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 be a const and this is not correct syntax
… but in a much better place than before
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