-
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
JS Scrabble - Angela - Octos #44
base: master
Are you sure you want to change the base?
Conversation
JS ScrabbleWhat We're Looking For
|
{ | ||
"a": { "points": 1, "tiles": 9 }, | ||
"b": { "points": 3, "tiles": 2 }, | ||
"c": { "points": 3, "tiles": 2 }, |
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.
Nice work tying together point values and tile counts in one data structure - very clever.
if (!word.match(/^[a-zA-Z]+$/)) { | ||
throw "Not a valid word"; | ||
} else if (word.length === 0) { | ||
throw "No word given"; |
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.
Instead of throwing a string, you should throw an instance of Error
. That gives you access to stack trace information. Something like this:
if (condition) {
throw new Error(`Invalid word ${word}`);
}
breakTie(topWord, word) { | ||
if ( topWord.length === 7 ) { | ||
return topWord; | ||
} else if (word.length === 7) { |
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 a helper function to clarify this logic.
highestScoringWord() { | ||
if (this.plays.length === 0) { | ||
throw "No words played"; | ||
} |
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.
You should be reusing the scoring logic from highestScoreFrom
here.
JS Scrabble
Congratulations! You're submitting your assignment!
Comprehension Questions