Conversation
| for (const ele of letters) { | ||
| for (const letter of ele) { | ||
| letterList.push(letter); | ||
| } | ||
| } |
There was a problem hiding this comment.
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.
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.
Remember we want to keep those constant variables at the top of our files
|
|
||
|
|
||
| return sumScore; | ||
|
|
| let scores = Object.values(wordListDict); | ||
| let highestWordScore = Math.max(...scores); |
There was a problem hiding this comment.
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.
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.
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.