Conversation
…s than the total amount of that letter
… quanity of letters in hand
| const lettersDrawnForHand = []; | ||
|
|
||
| while (lettersDrawnForHand.length < 10) { | ||
| let randomLetter = generateRandomLetter(); |
There was a problem hiding this comment.
So, when you defined generateRandomLetter, you make a call of createLetteList in it to create your list of letters from your LETTER_POOL. With this being said, every iteration of your while loop will make a new list of letters even though we don't really need a new list (it will look the same every time). I would suggest pulling it out of this function and calling createLetterList somewhere above the while loop in this function.
| // handles the correct quantity of letters in hand | ||
| export const usesAvailableLetters = (input, lettersInHand) => { | ||
| // Implement this method for wave 2 | ||
| const letterHandCopy = JSON.parse(JSON.stringify(lettersInHand)); |
There was a problem hiding this comment.
You are most likely aware of this now, but just in case you can make a copy array with the spread syntax like so [...lettersInHand].
| score += 8; | ||
| } | ||
|
|
||
| return score; |
| let highestScore = 0; | ||
| let highestScoringWord = ''; |
There was a problem hiding this comment.
If we know we want to return these variables in object form, could just initialize said object here?
| highestScoringWord = word; | ||
| } | ||
| else if (score === highestScore) { | ||
| if(highestScoringWord.length != 10 && (word.length === 10 || word.length < highestScoringWord.length)) { |
There was a problem hiding this comment.
Love the compound if statement very easy to follow!
| return { | ||
| 'score': highestScore, | ||
| 'word': highestScoringWord | ||
| } |
There was a problem hiding this comment.
Nice job, Megs! 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.