-
Notifications
You must be signed in to change notification settings - Fork 20
Ocelots - Diana A. #6
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
base: main
Are you sure you want to change the base?
Conversation
|
|
||
| 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.
One idea here could be using spread syntax, as an alternate to making a copy. Way to go on figuring out something that worked!
| const letters = []; | ||
|
|
||
| const keys = Object.keys(letterPoolCopy); | ||
| while (letters.length < 10) { |
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 loops makes sense, and I don't think you really have to worry about it here, but when I see
while loops like this, I think about adding some other kind of guard condition- like limiting the
number of attempts, for example-- to catch a possible infinite loop if there weren't enough letters
to be picked.
|
|
||
| for (let i = 0; i < input.length; i++) { | ||
| if (letterBankCopy.includes(input[i])) { | ||
| delete letterBankCopy[i]; |
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.
nice use of delete
No description provided.