-
Notifications
You must be signed in to change notification settings - Fork 50
Yasmin-Leaves #31
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?
Yasmin-Leaves #31
Conversation
JS AdagramsWhat We're Looking For
|
let randomLetter = avaLetters[index]; | ||
// remove the randomLetter from avaLetters array | ||
avaLetters.splice(index, 1); | ||
handOfLetters.push(randomLetter); |
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.
splice
returns the deleted elements, so you can smoosh these lines together like so:
handOfLetters.push( avaLetters.splice(index, 1) );
const onePointLetter = ['A', 'E', 'I', 'O', 'U', 'L', 'N', 'R', 'S', 'T']; | ||
const twoPointLetter = ['D', 'G']; | ||
const threePointLetter = ['B', 'C', 'M', 'P']; | ||
const fourPointLetter = ['F', 'H', 'V', 'W', 'Y']; | ||
const fivePointLetter = ['K']; | ||
const eightPointLetter = ['J', 'X']; | ||
const tenPointLetter = ['Q', 'Z']; | ||
|
||
let letters = word.toUpperCase().split(''); | ||
const scores = letters.map((letter) => { | ||
let letterScore = 0; | ||
|
||
if (onePointLetter.includes(letter)) { | ||
letterScore += 1; | ||
} else if (twoPointLetter.includes(letter)) { | ||
letterScore += 2; | ||
} else if (threePointLetter.includes(letter)) { | ||
letterScore += 3; | ||
} else if (fourPointLetter.includes(letter)) { | ||
letterScore += 4; | ||
} else if (fivePointLetter.includes(letter)) { | ||
letterScore += 5; |
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 ends up being pretty difficult to read and check. I would suggest using a JS Object in the form of
hashStyleScores = {
'A': 1,
'B': 4
}
This format makes it easy to find and change each letter, and means that scoring a single letter is a one-line operation!
remove references to Adagrams object
JS Adagrams
Congratulations! You're submitting your assignment!
Comprehension Questions