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

Nadia Sarkissian Zoisite #79

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open

Nadia Sarkissian Zoisite #79

wants to merge 8 commits into from

Conversation

pizzagirl1
Copy link

No description provided.

Copy link

@kelsey-steven-ada kelsey-steven-ada left a comment

Choose a reason for hiding this comment

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

Great work on your first javascript project 🎉 I've added some questions & comments below, please take a look when you have a moment and reach out here or on Slack if I can clarify anything =]

src/adagrams.js Outdated
@@ -1,15 +1,102 @@
export const drawLetters = () => {
// Implement this method for wave 1
};
const LETTER_POOL = {

Choose a reason for hiding this comment

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

Since this is a local variable of a function, the best practice is to use camel case for the naming: letterPool

Copy link
Author

Choose a reason for hiding this comment

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

Ohh, I kept it in all-caps since we treated it like a constant variable the first time. I wasn't confident about doing all-caps here instead of camelCase.

'Z': 1
};

const shuffleArray = array => {

Choose a reason for hiding this comment

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

Neat use of a nested function!

src/adagrams.js Outdated
Comment on lines 28 to 29
const playerHand = letterBag.slice(0, 10);
return playerHand;

Choose a reason for hiding this comment

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

Since this is a pretty short statement and we don't alter playerHand after creating it, I'd consider directly returning letterBag.slice(0, 10);.

src/adagrams.js Outdated

for (let letter of input) {
const letterIsUnavailable = (letterHashTable[letter] === 0)
|| !(letter in letterHashTable);

Choose a reason for hiding this comment

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

When dropping a statement across lines, I recommend indenting the continuations one further than the initial line to make it visually clear they are related and the continuations aren't their own new statements.

Copy link
Author

Choose a reason for hiding this comment

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

I always forget what the best way to do the indentation is! I knew this looked funny.

src/adagrams.js Outdated
Comment on lines 72 to 74
if (word.length >= 7) {
score += 8;
}

Choose a reason for hiding this comment

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

This could be a great place for a ternary operator:

// Ternary operator structure: 
// var = (conditional) ? (value if true) : (value if false)
score = (word.length >= 7) ? (score + 8) : score

src/adagrams.js Outdated
Comment on lines 93 to 99
if (winningWord.word.length === 10){
continue;
} else if (thisWord.word.length === 10
|| thisWord.word.length < winningWord.word.length){
winningWord = thisWord;
}
}

Choose a reason for hiding this comment

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

Since the result is no change for the first conditional, we could refactor to remove the continue. There are many ways to approach it, one option is to use variables to represent the conditionals we need to consider:

const isBestTen = winningWord.word.length === 10
const isWordTen = thisWord.word.length === 10
const isWordShorter = thisWord.word.length < winningWord.word.length
if ((isWordTen && !isBestTen) || (isWordShorter && !isBestTen)) {
    winningWord = thisWord;
}

Copy link
Author

Choose a reason for hiding this comment

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

i love how you set up these complex conditionals! Thank you for this. My spidey sense started tingling ISO a refactor when I had one line that was just "continue"

score: null
}

for (let word of words){

Choose a reason for hiding this comment

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

Great tie breaking in a single loop!

Copy link
Author

Choose a reason for hiding this comment

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

you said the same thing last time! :P

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