C22 Phoenix - Tatyana Venanzi#37
Conversation
kelsey-steven-ada
left a comment
There was a problem hiding this comment.
Nice work translating Adagrams to Javascript! Let me know if you have questions on any feedback =]
| } | ||
| } | ||
| let hand = []; | ||
| for (let i = 0; i < 10; i++) { |
There was a problem hiding this comment.
This loop declares a variable i, but we never use that variable inside the loop. A while loop that runs until the hand array has 10 elements might be a better fit.
| for (const letter of upperCaseInput) { | ||
| if (copyLettersInHand.includes(letter)) { | ||
| const index = copyLettersInHand.indexOf(letter); | ||
| copyLettersInHand.splice(index,1); | ||
| } else { | ||
| return false; | ||
| } | ||
| } |
There was a problem hiding this comment.
This implementation has an O(n^2) time complexity, how could we use a frequency map to bring the time complexity down to O(n)?
|
|
||
| export const usesAvailableLetters = (input, lettersInHand) => { | ||
| // Implement this method for wave 2 | ||
| const copyLettersInHand = [...lettersInHand]; |
There was a problem hiding this comment.
Nice use of the spread operator to copy lettersInHand!
| for (const letter of word) { | ||
| totalScore += LETTER_SCORES[letter] || 0; | ||
| } | ||
| return totalScore += word.length >= 7 ? 8 : 0; //ternary expression |
There was a problem hiding this comment.
Love a good ternary expression ^_^
I would recommend removing the comment at the end or reframing it to describe the purpose of this ternary expression.
No description provided.