-
Notifications
You must be signed in to change notification settings - Fork 710
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
zoisite gwen #57
base: main
Are you sure you want to change the base?
zoisite gwen #57
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.
Nice job on js-adagrams! I left some comments about using const instead of let. In general, you should always use const and then switch to let if you realize you need to re-assign the variable.
Also, beware of using proper white spacing when writing code. Have a look at a javascript style guide if you're needing a refresher on where whitespaces should go.
Additionally, I'd like to see smaller more frequent commits that help illustrate the history of your work.
@@ -145,7 +146,7 @@ describe("Adagrams", () => { | |||
const words = ["XXX", "XXXX", "X", "XX"]; | |||
const correct = { word: "XXXX", score: scoreWord("XXXX") }; | |||
|
|||
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.
👍
|
||
|
||
|
||
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.
We should name the variable with all caps and underscores to indicate that this is a constant variable LETTER_POOL
'Y': 2, | ||
'Z': 1 | ||
}; | ||
const pointValues = { |
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.
Constant variable should be named with all caps like POINT_VALUES
@@ -120,7 +120,8 @@ describe("Adagrams", () => { | |||
}); | |||
|
|||
it("returns a score of 0 if given an empty input", () => { | |||
throw "Complete test"; | |||
const word = ''; | |||
expect(scoreWord(word)).toBe(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.
👍
totalPoints += 8; | ||
} | ||
|
||
for(let index in 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.
Since the variable index
is not being reassigned in the for loop, we should use const here. Also, it's more descriptive to name the variable letter
since the elements we're iterating over in word
are the individual letters not a numerical index value
let wordPoints = {}; | ||
let pointList = []; | ||
|
||
for(let word of words){ | ||
let points = 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
let wordPoints = {}; | ||
let pointList = []; | ||
|
||
for(let word of words){ |
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.
Nitpick - proper whitespaces missing
for(let word of words){ | ||
let points = scoreWord(word) | ||
pointList.push(points) | ||
if(points in wordPoints){ |
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.
Nitpick - proper white spaces missing for this if statement
return {'word' : currentWinner, 'score': highestPoints}; | ||
} | ||
|
||
let range = highestScoredWords.length - 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.
Use const
for(let i=1; i <= range; i++){ | ||
if(currentWinner.length === 10){ | ||
return {'word' : currentWinner, 'score': highestPoints}; | ||
} else if((highestScoredWords[i]).length === 10){ | ||
return {'word' : highestScoredWords[i], 'score': highestPoints}; | ||
} else if(currentWinner.length > (highestScoredWords[i]).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.
Fix up whitespaces around these statements.
aaaaaaa ty ashley