Skip to content

Conversation

@cfissell50
Copy link
Owner

Checkpoint Rubric

This is the rubric that your instructor will use to grade your checkpoints. Please do not edit.

Checkpoint 1

  • All tests passed: 40 points
  • Proper use of documentation (commenting on code): 15 points
  • Properly indented code: 15 points
  • Demonstrated effective use of JavaScript: 30 points

Checkpoint 2

  • The application works as it should: 40 points
  • Proper use of documentation (commenting on code): 15 points
  • Properly indented code: 15 points
  • Demonstrated effective use of JavaScript and the DOM API: 30 points

Checkpoint 3

  • Use of React: 25 points
  • Accesses an API: 25 points
  • Proper use of documentation (commenting on code): 25 points
  • The application functions as it should: 25 points

Copy link

@stu-k stu-k left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice logic here, but a couple things need work. When you check for something like if (array.pop()) you are changing the array, but not saving what is popped. Also, the isLegal() function should have been checked in the if statement to determine if the movePiece() function should have been called. Pretty clean syntax, just some notes here and there.

// Your code here
// movePiece should use array method and dot method to select last index and grab it through push and pop
const movePiece = (startStack, endStack) => {
stacks[endStack].push(stacks[startStack].pop());
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very concise!


// Hierarchy of logic, if the stack has nothing in it, legal move, else the starting index popped should be less then the pop of the end stack. Or else move will not work.
const isLegal = (startStack, endStack) => {
if (stacks[endStack].length === 0) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens if the startStack is empty?

const isLegal = (startStack, endStack) => {
if (stacks[endStack].length === 0) {
return true;
} else if (stacks[startStack].pop() < stacks[endStack].pop()) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.pop() changes the array, we just want to check the value of the last item in the stack if there is one ( array[array.length - 1] ).

// use previous functions to put game together
// if move function is valid run call back legal function, if nothing else run win function.
const towersOfHanoi = (startStack, endStack) => {
if (movePiece(startStack, endStack)) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

movePiece() doesn't check anything, it moves pieces. Here, you're moving the pieces, and since movePiece will return undefines, isLegal won't even run.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants