-
Notifications
You must be signed in to change notification settings - Fork 169
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
SL - Presley #132
base: main
Are you sure you want to change the base?
SL - Presley #132
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 job! Let me know if you have any questions about the comments.
I think I found part of the bug in the method that handles ties that's leading to some tests failing and left a comment to call your attention to it
// Implement this method for wave 1 | ||
const handOfLetters = []; | ||
|
||
const lettersPool = { |
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.
Since this is hardcoded value that shouldn't change (which it can't because you use const
), you can rename this variable to LETTERS_POOL
const pool = []; | ||
for (const [letter, quantity] of Object.entries(lettersPool)) { |
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 job using const for these variables here
pool.splice(getTheNum, 1); | ||
}; | ||
|
||
return handOfLetters | ||
}; |
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.
The helper functions createPool and getNum should be created outside of the function drawLetters, but since they'd all be in the adagrams.js file, your drawLetters function will still be able to access them.
If you want to read more about benefits/disadvantages to nested functions, here's a resource: https://evgenii.info/nested-functions/
export const usesAvailableLetters = (input, lettersInHand) => { | ||
// Implement this method for wave 2 | ||
const lettersInHandCopy = [...lettersInHand]; | ||
const turnUpperCase = input.toUpperCase(); |
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.
Usually we use verbs for variables that refer to a function that does something. You could rename this to upperCaseWord
. If you had a custom method that had logic to make a word uppercase different from the built in one you used then turnUpperCase
would be great for that.
// This wave is still failing one test and I'm stuck on how to get it | ||
// to return 0 | ||
|
||
const letterScores = { |
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.
Could also rename this with caps and underscore to indicate it's a hardcoded value that shouldn't be changed, like LETTER_SCORES
// This wave is still failing one test and I'm stuck on how to get it | ||
// to return 0 |
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.
I ran the tests for scoreWord and they passed on my end. Your logic looks fine. I do see the tests for tied scores failing.
if(word === '') { | ||
return totalScore; | ||
} |
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 can get rid of this here because if word
is an empty string then no iterating will happen on line 118-120, and then your method returns totalScore which is still 0 (unchanged since none of the logic ran)
} | ||
} | ||
|
||
if (maxWords.length === 1) { |
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.
I think the issue with the logic for handling ties is here. When I ran the tests, I saw there were times when maxWords.length != 1 (instead it had 2 words in it)
Struggled a bit with wave 4 - not really sure if the direction I was going made sense. Thanks for all your patience as I catch up, it's much appreciated <3 :)