-
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
Heather M SeaTurtles js-adagrams #94
base: main
Are you sure you want to change the base?
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.
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 = () => { |
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 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; |
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.
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;
};
if (word.length > 6) { | ||
score += 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 could also use a ternary here and would look like
let score = word.length >= 6 ? 8 : 0;
return score; | ||
}; | ||
|
||
export const getIndexTieBreak = (highestScoringWords) => { |
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.
👍🏽
highestIndex = i; | ||
} | ||
} | ||
return highestIndex; | ||
}; | ||
|
||
export const highestScoreFrom = (words) => { |
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.
👍🏽
No description provided.