Skip to content
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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Sharks - Ivana #104

wants to merge 4 commits into from

Conversation

maldonado-ivana
Copy link

No description provided.

Copy link

@yangashley yangashley left a 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",

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)) {

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++) {

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)

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

Comment on lines +71 to +76
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);
}

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) {

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

Comment on lines +97 to +101
let totalScore = 0;

if (word.length >= 7) {
totalScore += 8
}

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

Comment on lines +103 to +105
for (let letter of word.toUpperCase()){
totalScore += letterScores[letter]
}

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants