Skip to content
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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

C17 Otters - Ada Barries #115

wants to merge 4 commits into from

Conversation

adabarries
Copy link

submitting what i have

Copy link

@kendallatada kendallatada left a 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);

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) {

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) {

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)

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants