-
Notifications
You must be signed in to change notification settings - Fork 44
C22 Phoenix - Tatyana Venanzi #37
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
base: main
Are you sure you want to change the base?
Conversation
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 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.