-
Notifications
You must be signed in to change notification settings - Fork 50
Leaves - Elizabeth #43
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?
Conversation
JS AdagramsWhat We're Looking For
|
@@ -1,7 +1,104 @@ | |||
const Adagrams = { | |||
drawLetters() { | |||
// Implement this method for wave 1 | |||
// eslint-disable-next-line max-len | |||
const letters = ['A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'B', 'B', 'C', 'C', 'D', 'D', 'D', 'D', 'E', 'E', 'E', 'E', 'E', 'E', 'E', 'E', 'E', 'E', 'E', 'E', 'F', 'F', 'G', 'G', 'G', 'H', 'H', 'I', 'I', 'I', 'I', 'I', 'I', 'I', 'I', 'I', 'J', 'K', 'L', 'L', 'L', 'L', 'M', 'M', 'N', 'N', 'N', 'N', 'N', 'N', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'P', 'P', 'Q', 'R', 'R', 'R', 'R', 'R', 'R', 'S', 'S', 'S', 'S', 'T', 'T', 'T', 'T', 'T', 'T', 'U', 'U', 'U', 'U', 'V', 'V', 'W', 'W', 'X', 'Y', 'Y', 'Z']; |
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 might store a hash of letter frequencies like this
letterQuantities: {
A: 9, B: 2, ...
}
and use it to build a pool of letters dynamically.
return array; | ||
}; | ||
|
||
const randomOrder = shuffleLetters(letters) |
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.
Here, you shuffle the entire array pool of letters... and then, you take the first ten. I think you could refactor this so that you randomly pick ten letters, instead of shuffling the entire array.
|
||
const letters = input.split('') | ||
|
||
letters.forEach(char => { |
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 using a loop that allows you to break out so that as soon as you encounter a false
you exit the loop.
}, | ||
|
||
scoreWord(input) { | ||
const letterPoints = { |
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.
style note: move this object to ahead of all the functions, but inside the module.
JS Adagrams
Congratulations! You're submitting your assignment!
Comprehension Questions