-
Notifications
You must be signed in to change notification settings - Fork 41
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
Kayla Ecker - Caret #44
base: master
Are you sure you want to change the base?
Conversation
JS ScrabbleWhat We're Looking For
|
score: function(word) { | ||
// TODO: implement score | ||
} | ||
score: function(word) { |
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 could be written as:
score(word) {
} | ||
score: function(word) { | ||
|
||
let regex = /^[a-zA-Z]+$/; |
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.
Making variables you never reassign const
is a good idea.
let score = 0; | ||
|
||
|
||
for (let i = 0; i < lowercaseWord.length; i++) { |
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 works fine, you can also use reduce
to calculate it.
Scrabble.Player = class { | ||
constructor(name) { | ||
if (name === undefined) { | ||
throw new Error('Invalid - must be a name'); |
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 work creating an object to throw the error.
play(word) { | ||
let regex = /^[a-zA-Z]+$/; | ||
|
||
if (word === undefined || !regex.test(word)) { |
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 use of Regex
JS Scrabble
Congratulations! You're submitting your assignment!
Comprehension Questions