-
Notifications
You must be signed in to change notification settings - Fork 50
Leaves - Julia K #27
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: master
Are you sure you want to change the base?
Leaves - Julia K #27
Conversation
…idea how to pull letters from a JavaScript object -- hey, it's only the first week.
…o count letters drawn.
…t of a letter than is in letter pool. Added this logic to function. Passing wave 1 tests.
… containing 2 Zs. Now it is.
…hat tallies the count of each letter.
… return values in the right place.
// code for random courtesy of https://stackoverflow.com/questions/4550505/getting-a-random-value-from-a-javascript-array | ||
// pull a random letter from the letter pool array | ||
let randomLetter = letterPoolArray[Math.floor(Math.random() * letterPoolArray.length)]; | ||
// condition: if adding the letter to the player hand would exceed the count of letters in the pool, redraw |
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.
yes! nice work on this logic and clear comments describing what's going on.
// Implement this method for wave 1 | ||
const letterPoolHash = {'A':9, 'B':2, 'C':2, 'D':4, 'E':12, 'F':2, 'G':3, 'H':2, 'I':9, 'J':1, 'K':1, 'L':4, 'N':6, 'O':8, 'P':2, 'Q':1, 'R':6, 'S':4, 'T':6,'U':4, 'V':2, 'W':2, 'X':1, 'Y':2, 'Z':1 }; | ||
|
||
const letterPoolArray = ['A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'B', 'B', |
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 data structure works, but it's not very DRY and would be tricky to change. For example, suppose I said you had the wrong number of "I"s - you would have to do a lot of counting to solve the problem.
Instead you could use your hash of letter frequencies to create this array dynamically.
} | ||
}); | ||
|
||
// loop over handHash: if letter count in input is ever greater than letter count in hash, return false. Else return true. |
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.
Consider whether it would have been possible to do this check in the for loop above (had that not been a forEach loop)?
let wordArray = word.toUpperCase().split('') | ||
let score = 0 | ||
|
||
if (wordArray.length >= 7) { |
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 forgot && wordArray.length <= 10)
JS AdagramsWhat We're Looking For
|
…-5.2.3 Bump ws from 5.2.2 to 5.2.3
JS Adagrams
Congratulations! You're submitting your assignment!
Comprehension Questions