Conversation
There was a problem hiding this comment.
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.
| const correct = { word: "XXXX", score: scoreWord("XXXX") }; | ||
|
|
||
| throw "Complete test by adding an assertion"; | ||
| expect(highestScoreFrom(words)).toEqual(correct); |
|
|
||
|
|
||
|
|
||
| const letterPool = { |
There was a problem hiding this comment.
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.
Constant variable should be named with all caps like POINT_VALUES
| it("returns a score of 0 if given an empty input", () => { | ||
| throw "Complete test"; | ||
| const word = ''; | ||
| expect(scoreWord(word)).toBe(0); |
| totalPoints += 8; | ||
| } | ||
|
|
||
| for(let index in word){ |
There was a problem hiding this comment.
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) |
| let wordPoints = {}; | ||
| let pointList = []; | ||
|
|
||
| for(let word of words){ |
There was a problem hiding this comment.
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.
Nitpick - proper white spaces missing for this if statement
| return {'word' : currentWinner, 'score': highestPoints}; | ||
| } | ||
|
|
||
| let range = highestScoredWords.length - 1; |
| 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.
Fix up whitespaces around these statements.
aaaaaaa ty ashley