-
Notifications
You must be signed in to change notification settings - Fork 103
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
Amethyst- Stacy #75
base: main
Are you sure you want to change the base?
Amethyst- Stacy #75
Conversation
@@ -1,15 +1,94 @@ | |||
export const drawLetters = () => { | |||
// Implement this method for wave 1 | |||
var letters = { |
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'm sure you know this now but we want to avoid using var
, I think here we could use const
instead.
const weighted = (dict, randomPiece) => { | ||
for (let [key, value] of Object.entries(dict)){ | ||
randomPiece -= value; | ||
if (randomPiece <= 0){ | ||
return key; | ||
} | ||
} |
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.
Love this function! For readability we want to make sure we are placing our function definitions above the calls.
}; | ||
|
||
export const usesAvailableLetters = (input, lettersInHand) => { | ||
// Implement this method for wave 2 | ||
let newLetterBank = []; |
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.
We could make a new letter bank with the Javascript spread syntax like so newLetterBank = [...lettersInHand]
sum += values[letter.toUpperCase()]; | ||
} | ||
} | ||
return sum; |
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.
⭐️
let maxVal = 0; | ||
let tempScore = 0; | ||
let maxWord = ""; |
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.
If we know we want to return these variables in object form, could just initialize said object here?
maxVal = tempScore; | ||
maxWord = word; | ||
} | ||
else if(maxVal == tempScore){ |
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.
Love the if statements in this function, they are very concise!
} | ||
} | ||
}; | ||
return {"word": maxWord, "score": maxVal}; |
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 job, Stacy! As you probably noticed, I didn't give too much feedback due to the scope of the project (Translating your python code to Javascript code). I tried to just point out any glaring issues, if any. With that being said, if you want to discuss anything in greater detail, feel free to reach out to me!
No description provided.