-
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
C19 Zoisite | Yvett J. #88
base: main
Are you sure you want to change the base?
Conversation
… copy and take pieces out of pool as pieces are added into the hand
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.
Good work on js-adagrams!
There are several places that you should use const over let. Prefer to use const over let and refactor the variable to use let when you need it.
Let me know if you have questions about my comments!
@@ -145,7 +148,8 @@ describe("Adagrams", () => { | |||
const words = ["XXX", "XXXX", "X", "XX"]; | |||
const correct = { word: "XXXX", score: scoreWord("XXXX") }; | |||
|
|||
throw "Complete test by adding an assertion"; | |||
// 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.
👍
expectScores({ | ||
'': 0, | ||
}) |
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.
👍
@@ -1,15 +1,121 @@ | |||
export const drawLetters = () => { | |||
// Implement this method for wave 1 | |||
const 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.
since letters is a constant variable it should be spelled with all caps like LETTERS
let hand = []; | ||
let letters2 = [...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.
Use const instead of let since neither variables are reassigned. A general rule of thumb for me when writing javascript is to use const and only refactor to let if the JS interpreter throws an exception when I try to reassign a variable.
Also prefer a more descriptive variable name like lettersCopy
'X', | ||
'Y', 'Y', | ||
'Z' | ||
]; |
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.
While it was not a requirement for this project to use a dictionary with letters for keys and number of letters for values to create a list of 98 letters, I would prefer to see you do that in order to get practice iterating over a dictionary to create a new data structure.
}; | ||
|
||
export const scoreWord = (word) => { | ||
// Implement this method for wave 3 | ||
const letterScores = { |
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 this is a constant variable, we should name the variable with all caps like LETTER_SCORES
score += 8; | ||
} | ||
|
||
for (let letter of inputLetters) { |
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.
Use const instead of let for the looping variable letter
since the variable is not reassigned in the loop
for (let word of words) { | ||
let score = scoreWord(word); |
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.
Use const
}; | ||
|
||
export const highestScoreFrom = (words) => { | ||
// Implement this method for wave 4 | ||
let winningWord = ''; | ||
let topScore = 0; | ||
let wordsWithScores = []; |
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.
wordsWithScores isn't ever reassigned so we should use const instead of let
let currentWord = wordSet['word']; | ||
let currentScore = wordSet['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.
Use const
No description provided.