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

Otters | Tori Shade #95

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

Otters | Tori Shade #95

wants to merge 2 commits into from

Conversation

ToriShade
Copy link

Godbless, Goeun. JavaScript is a garbage language.

Copy link

@goeunpark goeunpark left a comment

Choose a reason for hiding this comment

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

Wonderful job, Tori! 🎉

Your for/while loops iterate beautifully, your tests pass, and your consistent use of semicolons make my inner JS developer so happy! Great job, this project is a Green. 🟢

Let me know if you have any questions on this feedback. Keep up the great work! 🚀

export const drawLetters = () => {
// Implement this method for wave 1

let letterPoolCopy = JSON.parse(JSON.stringify(letterPool));

Choose a reason for hiding this comment

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

Alternatively, you could use the spread operator here to make a copy:

letterPoolCopy = { ...letterPool };

@@ -1,15 +1,140 @@
const letterPool = {

Choose a reason for hiding this comment

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

Since we know that we won't mutate or reassign letterPool or letterValues, these would be great values to make into constants by notating LETTER_POOL and LETTER_VALUES.

const letters = [];
while (letters.length < 10) {
const alphabet = Object.keys(letterPool);
const letterDrawn = alphabet[Math.floor(Math.random() * alphabet.length)];

Choose a reason for hiding this comment

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

This doesn't quite mimic the same probabilities as putting all the tiles in a bag and picking ten tiles.

When the program randomly picks on L69, it's a random pick of the 26 letters in the alphabet. That means A and Z both have 1/26th chance of being picked before we do the validation check, despite the letter bag distribution for A being 9/98 and Z being 1/98.

};



export const drawLetters = () => {
// Implement this method for wave 1

Choose a reason for hiding this comment

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

Clear out these comments to make production-ready code!

export const drawLetters = () => {
// Implement this method for wave 1

let letterPoolCopy = JSON.parse(JSON.stringify(letterPool));

Choose a reason for hiding this comment

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

You can use a spread operator as well:

let letterPoolCopy = { ...letterPool };

Comment on lines +151 to +152
//throw "Complete test by adding an assertion";
expect(highestScoreFrom(words)).toEqual(correct);

Choose a reason for hiding this comment

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

👍🏻

};

export const usesAvailableLetters = (input, lettersInHand) => {
// Implement this method for wave 2

let lettersInHandCopy = JSON.parse(JSON.stringify(lettersInHand));

Choose a reason for hiding this comment

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

You can use a spread operator as well:

let lettersInHandCopy = [ ...lettersInHand ];

Comment on lines +106 to +108
if (input.length > 6 && input.length < 11) {
score += 8;
}

Choose a reason for hiding this comment

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

Wonderful use of the && operator in this conditional check!

Comment on lines +120 to +138
for (let word of words) {
let score = scoreWord(word);
if (score > highest["score"]) {
highest["word"] = word;
highest["score"] = score;
}
else if (score === highest["score"]) {
if (highest["word"].length === 10) {
return highest;
}
else if (word.length === 10 && highest["word"].length !== 10) {
highest["word"] = word;
highest["score"] = score;
}
else if (word.length < highest["word"].length) {
highest["word"] = word;
highest["score"] = score;
}
}}

Choose a reason for hiding this comment

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

Great set of conditional logic here to get highest scores!

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