Conversation
| function checkForWin() { | ||
| // Your code here | ||
|
|
||
| if (stacks.c[3] === 1){ //checks for the "1" block on top of a four-stack in stack "c." |
There was a problem hiding this comment.
i like that you reset the board.
Checking to see if the last piece is 1 assumes that the reset of your code will not let that happen.
While this is logically correct, a better approach might have been to verify that the a and b stacks are empty and the c stack - 4,3,2,1
| //console.log("Length of startStack: " + begin.length); | ||
| //console.log("Value of block being moved: " + begin[begin.length - 1]); | ||
| //console.log("Value of block being topped off: " + final[final.length - 1]); | ||
| if (begin[begin.length - 1] > final[final.length - 1]) { //making sure the "block" is being move onto a larger "block" |
There was a problem hiding this comment.
this should return a false if it is not a legal move.
Also checking for a legal move is a better approach. IE start out assuming the move is not legal unless you prove otherwise.
This implementation allows you to move piece back to its own stack. Not wrong just weird that it would be allowed.
| // Your code here | ||
|
|
||
| /* | ||
| *This function removes a block from a stack and adds that block to a different stack |
There was a problem hiding this comment.
I really like the documentation, and it was obvious you used log statements to debug as you were going along. Nice!
| //console.log("Length of startStack: " + begin.length); | ||
| //console.log("Value of block being moved: " + begin[begin.length - 1]); | ||
| //console.log("Value of block being topped off: " + final[final.length - 1]); | ||
| if (begin[begin.length - 1] > final[final.length - 1]) { //making sure the "block" is being move onto a larger "block" |
There was a problem hiding this comment.
You also allow me to move from an empty stack to another empty stack, or from an empty stack to a non-empty stack
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