-
Notifications
You must be signed in to change notification settings - Fork 234
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
Parsity Eval 1 #229
base: master
Are you sure you want to change the base?
Parsity Eval 1 #229
Conversation
}; | ||
|
||
return { | ||
initialDisplay: initialDisplay, |
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.
when the key matches the value you can use it like this:
initialDisplay: initialDisplay, | |
initialDisplay, |
|
||
//solvePuzzle(5, 1, 3, 2); | ||
|
||
// This was my attempt at winning the game. |
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.
THANKS for this
@@ -0,0 +1,139 @@ | |||
const TOHBoard = function () { |
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.
es6 arrow functions are more performant!
|
||
const displayBoard = function () { | ||
console.log("Current Board:"); | ||
for (const peg in boardObject) { |
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.
next time use an array helper like forEach
for (const peg in boardObject) { | ||
console.log(`${peg}: --- ${boardObject[peg]}`); | ||
} | ||
return board; |
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.
why are you returning the board?
}; | ||
|
||
const checkWinner = function () { | ||
const winCondition = [5, 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 can be defined once on top of the file and not re-defined each time.
|
||
const moveDisc = function (initialPeg, newPeg) { | ||
const initialArray = boardObject[initialPeg]; | ||
const newArray = boardObject[newPeg]; |
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 an issue here but objects are passed by reference and not value, this approach can create bugs in the future. You need to find a way to 'clone' the object for example with the spread operator (...), that creates a copy and its safer for the future.
boardObject[2] = []; | ||
boardObject[3] = []; | ||
board = [[5, 4, 3, 2, 1], [], []]; | ||
return board; |
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 every function needs to return something if its not in use.
No description provided.