-
Notifications
You must be signed in to change notification settings - Fork 50
Leaves - Bri #38
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 - Bri #38
Conversation
… is randomly generated
…ecial case letters are used
JS AdagramsWhat We're Looking For
|
"Z".repeat(1) | ||
).split(''); | ||
|
||
const valueHash = {"A": 1, "E": 1, "I": 1, "O": 1, "U": 1, "L": 1, "N": 1, "R": 1, "S": 1, "T": 1, "D": 2, "G": 2, "B": 3, "C": 3, "M": 3, "P": 3, "F": 4, "H": 4, "V": 4, "W": 4, "Y": 4, "K": 5, "J": 8, "X": 8, "Q": 10, "Z": 10}; |
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: each letter should be on it's own line.
In addtion, this notation
const valueHash = {A: 1, E: 1, ... }
will create
const valueHash = {"A": 1, "E": 1, ... }
`
@@ -1,8 +1,97 @@ | |||
const poolOfLetters = ( |
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.
It would be best to include each of these objects poolOfLetters
and valueHash
inside the Adagrams module (I know this is different then what I said last week :)
letterbank[i] = temp; | ||
} | ||
}, | ||
|
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. Consider how you could refactor this so that you randomly pick ten letters, instead of shuffling the entire array.
} | ||
} | ||
|
||
// Check if characters from input are in handHash |
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 seems overly nested. Consider how your might refactor using compound conditionals.
usesAvailableLetters(input, lettersInHand) { | ||
|
||
// Create frequency hash of lettersInHand | ||
let handHash = new Object(); |
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 this syntax let handHash = {}
// Create frequency hash of lettersInHand | ||
let handHash = new Object(); | ||
for (let l of lettersInHand) { | ||
if (handHash.hasOwnProperty(l)) { |
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.
.hasOwnProperty
if not necessary here
if (handHash[l]
works
for (let l of word) { | ||
score += valueHash[l.toUpperCase()]; | ||
} | ||
if (word.length == 7 || word.length == 8 || word.length == 9 || word.length == 10){ |
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 word.length > 6 && word.length < 11
JS Adagrams
Congratulations! You're submitting your assignment!
Comprehension Questions