-
Notifications
You must be signed in to change notification settings - Fork 112
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
C17 Otters - Ada Barries #115
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.
Hi Ada! Your submission has been scored as green. I left some comments in your code. Nice job!
let inputSet = new Set(upperCaseInput); | ||
let handSet = new Set(lettersInHand); | ||
|
||
const extraLetters = (inputSet - handSet); |
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.
Great usage of sets! ✨
return false; | ||
} | ||
|
||
for (let i in upperCaseInput) { |
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.
Your set comparison already took care of finding out if the letters in the input word exist in the hand so this loop isn't necessary.
if (word.length >= 7) { | ||
wordScore += 8; | ||
} | ||
for (let i in upperCaseWord) { |
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.
You could use a for ... of
loop here to iterate directly over the string characters rather than the index
// within the above forEach loop if (currentScore > maxScore) { | ||
// maxScore = currentScore; | ||
// } | ||
// loop again through words. (forEach again? there's deffo a better way to do this) |
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.
Your pseudocode made me chuckle lol. You're on the right track though! It is possible to find the highest scoring word with only one loop. Rather than building a list of words that have the highest score, think about how you can keep track of the current highest scoring word as you iterate over the list of words and how you could compare each word to the current best word.
submitting what i have