-
Notifications
You must be signed in to change notification settings - Fork 169
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
base: main
Are you sure you want to change the base?
Conversation
for (const ele of letters) { | ||
for (const letter of ele) { | ||
letterList.push(letter); | ||
} | ||
} |
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 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 |
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.
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 | ||
}; |
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.
Remember we want to keep those constant variables at the top of our files
|
||
|
||
return sumScore; | ||
|
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.
✨
let scores = Object.values(wordListDict); | ||
let highestWordScore = Math.max(...scores); |
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.
Love this! Especially the combination of spread syntax and the max
method.
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; | ||
} |
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.
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; | ||
|
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.
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!
No description provided.