-
Notifications
You must be signed in to change notification settings - Fork 112
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
Sharks - Ivana #104
base: main
Are you sure you want to change the base?
Sharks - Ivana #104
Conversation
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 on js-adagrams! Your project shows that you have a good handle on javascript so far!
I had a few minor comments about using const instead of let and an additional check you could add to scoreWord() so that you can handle scoring words that include characters that may not be in the alphabet.
🟢 for the project!
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"type": "pwa-node", |
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.
Is this for debugging JS in VSCode?
// Implement this method for wave 1 | ||
const arrayOfLetters = []; | ||
|
||
for (let [letter, quantity] of Object.entries(letterPool)) { |
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 we don't reassign letter
or quantity
could we use const
instead in the for loop?
const arrayOfLetters = []; | ||
|
||
for (let [letter, quantity] of Object.entries(letterPool)) { | ||
for (let i=0; i<quantity; 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.
Per js style, we should add spaces around operators
for (let i = 0; i < quantity; i++) {
Here's Google's JS styleguide: https://google.github.io/styleguide/jsguide.html
}; | ||
|
||
console.log(drawLetters) |
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.
Remember to remove debugging print statements
for (let i=0; i<10; i++) { | ||
const currentLetter = arrayOfLetters[Math.floor(Math.random() * arrayOfLetters.length)]; | ||
currentHand.push(currentLetter); | ||
arrayOfLetters.splice(arrayOfLetters.indexOf(currentLetter), 1); | ||
} | ||
|
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.
👍 looks good!
|
||
const upperCaseWord = input.toUpperCase(); | ||
|
||
for (let letter of upperCaseWord) { |
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.
We can use const
instead of let
here since we don't need to change the value of letter
let totalScore = 0; | ||
|
||
if (word.length >= 7) { | ||
totalScore += 8 | ||
} |
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 might also see this written with a ternary like:
let totalScore = word.length >= 7 ? 8 : 0;
which would replace what's on line 97
for (let letter of word.toUpperCase()){ | ||
totalScore += letterScores[letter] | ||
} |
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.
How would you handle input that has characters that are not in letterScores
, for example what if word was "cat!" ?
When your for loop gets to "!" then letterScores['!'] will return undefined
. When we add undefined
to a number like totalScore
then the result will be NaN, which introduces a bug.
You could have a conditional check before adding score to total, by checking that the letter is a key in letterScore.
No description provided.