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.
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.
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.
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.
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.
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.
.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.
consider word.length > 6 && word.length < 11
JS Adagrams
Congratulations! You're submitting your assignment!
Comprehension Questions