-
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
Selam Ainalem - Amperes #46
base: master
Are you sure you want to change the base?
Conversation
… letter and value as associated score. Created score(word), that has a word(string) as an input and returns the associated score. Created method highestScoreFrom(arrayOfWords) accepts an array of words returns the highest scoring word. All methods have only been tested in the terminal. git push origin master
…constructor that accepts a name of a player. Added play(word) - pushes played word into plays array, added totalScore() - calculates a player's total score. added hasWon() - checks if a player has won, added highestScoringWord() - returns highest scoring word, added highestWordScore() - returns the score for the highest scoring word.
…se is covered and passing.
… the highestSCoringWord() method from being invoked w/o a word being played. Also created a new test for highestWordScore().
…g invoked without a word being played. Tested method. All methods are currently passing. Need to update tests for edge cases.
JS ScrabbleWhat We're Looking For
|
const Scrabble = { | ||
score(word) { | ||
|
||
score_per_char(){ |
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 makes more sense to have this as an object rather than a function which returns an object.
throw new Error('Word length must be at least 1 character.') | ||
} | ||
|
||
if (/^[a-zA-Z]*$(?=)/.test(word) === false){ |
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.
👍
|
||
play(word){ | ||
if (word === null){ |
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.
Since both null
and undefined
are falsy, you could just do
if (!word) {
throw new Error(`${word} is not valid word`);
}
if (user_has_won){ | ||
return false | ||
}else { | ||
if (word.length) |
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.
What purpose does this if
statement serve?
} | ||
|
||
hasWon(){ | ||
if (this.totalScore() >= 100){ |
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 could also have:
return this.totalScore() >= 100;
JS Scrabble
Congratulations! You're submitting your assignment!
Comprehension Questions