-
Notifications
You must be signed in to change notification settings - Fork 42
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
Brenda Rios - Scrabble - Octos #32
base: master
Are you sure you want to change the base?
Conversation
…ests for score method passing
…test to pass for the constructor.
JS ScrabbleWhat We're Looking For
|
|
||
} else { | ||
throw "Word must only contain letters from A-Z and have less than or equal to 7 characters"; | ||
} |
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 might be a little cleaner to invert this conditional:
if (!(/^[a-zA-Z]+$/.test(word) && word.length <= 7)) {
throw new Error("Word must only contain letters from A-Z and have less than or equal to 7 characters");
}
// ... lines 11 through 20 ...
|
||
} else { | ||
throw "Word must only contain letters from A-Z and have less than or equal to 7 characters"; | ||
} |
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.
If you throw a regular string like you do on line 23, you don't get backtrace information! You should throw an instance of Error
instead (i.e. throw new Error("Word must...")
)
const winningWord = arrayOfWords.reduce((word1, word2) => { | ||
const scoreWord1 = Scrabble.score(word1); | ||
const scoreWord2 = Scrabble.score(word2); | ||
|
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.
Good use of reduce
here!
JS Scrabble
Congratulations! You're submitting your assignment!
Comprehension Questions