Skip to content
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

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open

Parsity Eval 1 #229

wants to merge 9 commits into from

Conversation

acl13
Copy link

@acl13 acl13 commented Jul 23, 2024

No description provided.

};

return {
initialDisplay: initialDisplay,

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:

Suggested change
initialDisplay: initialDisplay,
initialDisplay,


//solvePuzzle(5, 1, 3, 2);

// This was my attempt at winning the game.

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 () {

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) {

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;

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];

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];

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;

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.

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.

2 participants