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

Phalesa Patton - Amethyst #147

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

Phalesa Patton - Amethyst #147

wants to merge 5 commits into from

Conversation

PhePhe123
Copy link

No description provided.

Comment on lines +37 to +41
for (const ele of letters) {
for (const letter of ele) {
letterList.push(letter);
}
}

Choose a reason for hiding this comment

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

This line could be mitigated with using the Javascript spread syntax like so letters.push(...key.repeat(value))


while (drawnLetters.length < 10) {
const randomLetter = createRandomizer();
const occurences = drawnLetters.filter( letter => letter === randomLetter).length

Choose a reason for hiding this comment

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

Love how you used the filter method here, it is one of the most utilized Javascript methods, especially in React as you probably already seen.

'X':8,
'Q':10,
'Z':10
};

Choose a reason for hiding this comment

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

Remember we want to keep those constant variables at the top of our files



return sumScore;

Choose a reason for hiding this comment

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

Comment on lines +169 to +170
let scores = Object.values(wordListDict);
let highestWordScore = Math.max(...scores);

Choose a reason for hiding this comment

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

Love this! Especially the combination of spread syntax and the max method.

Comment on lines +181 to +205
if (highestWordList.length > 1) {
for (const word of highestWordList) {
if (word.length === 10) {
wordLenTenList.push(word);
resultDict['word'] = wordLenTenList[0];
resultDict['score'] = highestWordScore;
return resultDict
}
else {
const lens = highestWordList.map(words => words.length)
console.log(lens)
const shortestWord = Math.min(...lens)
for (const item of highestWordList) {
if (item.length === shortestWord) {
resultDict['word'] = item;
resultDict['score'] = highestWordScore;
}
}
}
}
}
else {
resultDict['word'] = highestWordList[0];
resultDict['score'] = highestWordScore;
}

Choose a reason for hiding this comment

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

I love the logic here, however the nesting can have a negative impact of the readibility of your code. I would consider looking at if some of the functionality of nested code blocks could be combined.

// console.log(wordLenTenList);
console.log(resultDict);
return resultDict;

Choose a reason for hiding this comment

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

Nice job, Pha'lesa! As you probably noticed, I didn't give too much feedback due to the scope of the project (Translating your python code to Javascript code). I tried to just point out any glaring issues, if any. With that being said, if you want to discuss anything in greater detail, feel free to reach out to me!

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