Skip to content

Phalesa Patton - Amethyst#147

Open
PhePhe123 wants to merge 5 commits intoAda-C18:mainfrom
PhePhe123:main
Open

Phalesa Patton - Amethyst#147
PhePhe123 wants to merge 5 commits intoAda-C18:mainfrom
PhePhe123:main

Conversation

@PhePhe123
Copy link
Copy Markdown

No description provided.

Comment thread src/adagrams.js
Comment on lines +37 to +41
for (const ele of letters) {
for (const letter of ele) {
letterList.push(letter);
}
}
Copy link
Copy Markdown

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

Comment thread src/adagrams.js

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

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.

Comment thread src/adagrams.js
'X':8,
'Q':10,
'Z':10
};
Copy link
Copy Markdown

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

Comment thread src/adagrams.js


return sumScore;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Comment thread src/adagrams.js
Comment on lines +169 to +170
let scores = Object.values(wordListDict);
let highestWordScore = Math.max(...scores);
Copy link
Copy Markdown

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 thread src/adagrams.js
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;
}
Copy link
Copy Markdown

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.

Comment thread src/adagrams.js
// console.log(wordLenTenList);
console.log(resultDict);
return resultDict;

Copy link
Copy Markdown

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