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

Heather M SeaTurtles js-adagrams #94

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

Heather M SeaTurtles js-adagrams #94

wants to merge 5 commits into from

Conversation

cathos
Copy link

@cathos cathos commented Jun 7, 2022

No description provided.

Copy link

@tgoslee tgoslee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Look good Heather! I left some suggestions for usesAvailableLetters and using a ternary operator. Make sure you remove any commented code once you are finished and push your final code! Let me know if you have questions.

Y: 2,
Z: 1,
};

export const drawLetters = () => {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a good approach! During our review, we also saw someone use a spread operator. A few different ways to do it! You can also go ahead and remove the commented code to clean it up.

// lettersInHand is an array of letters.
// this seems a bit long. Maybe I can use another method to count letter in ...
// or maybe I can make another function to do this.
const lettersArray = lettersInHand;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know you were thinking of another way to do this. Here is one way to do it with one for loop

export const usesAvailableLetters = (input, lettersInHand) => {
  const input_array = input.split("");
  const n = input.length;
  let lettersInHandCopy = [...lettersInHand];
  for (let i = 0; i < n; i++) {
    let letter = input_array[i];
    if (lettersInHandCopy.includes(letter)) {
      let j = lettersInHandCopy.indexOf(letter);
      lettersInHandCopy.splice(j, 1);
    } else {
      return false;
    }
  }
  return true;
};

Comment on lines +128 to +130
if (word.length > 6) {
score += 8;
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you could also use a ternary here and would look like

let score = word.length >= 6 ? 8 : 0;

return score;
};

export const getIndexTieBreak = (highestScoringWords) => {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏽

highestIndex = i;
}
}
return highestIndex;
};

export const highestScoreFrom = (words) => {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏽

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