-
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
Otters | Tori Shade #95
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.
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)); |
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.
Alternatively, you could use the spread operator here to make a copy:
letterPoolCopy = { ...letterPool };
@@ -1,15 +1,140 @@ | |||
const 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 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)]; |
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 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 |
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.
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)); |
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 can use a spread operator as well:
let letterPoolCopy = { ...letterPool };
//throw "Complete test by adding an assertion"; | ||
expect(highestScoreFrom(words)).toEqual(correct); |
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.
👍🏻
}; | ||
|
||
export const usesAvailableLetters = (input, lettersInHand) => { | ||
// Implement this method for wave 2 | ||
|
||
let lettersInHandCopy = JSON.parse(JSON.stringify(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.
You can use a spread operator as well:
let lettersInHandCopy = [ ...lettersInHand ];
if (input.length > 6 && input.length < 11) { | ||
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.
Wonderful use of the &&
operator in this conditional check!
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; | ||
} | ||
}} |
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.
Great set of conditional logic here to get highest scores!
Godbless, Goeun. JavaScript is a garbage language.