Salma Anany - C22- Sphinx#21
Conversation
| @@ -1,15 +1,110 @@ | |||
| const LETTER_POOL = { | |||
There was a problem hiding this comment.
👍 Nice job using capital letters to convey to other devs the value is fixed.
| const allLetters = [] | ||
| const hand = [] |
There was a problem hiding this comment.
Nice job using const for these two variables.
| // Implement this method for wave 1 | ||
| const allLetters = [] | ||
| const hand = [] | ||
| for (let key of Object.keys(LETTER_POOL)) { |
There was a problem hiding this comment.
Since key isn't reassigned in your loop, we should use const
| for (let key of Object.keys(LETTER_POOL)) { | |
| for (const key of Object.keys(LETTER_POOL)) { |
| allLetters.push(key) | ||
| } | ||
| } | ||
| for (let pepar = 0; pepar < 10; pepar++) { |
| } | ||
| } | ||
| for (let pepar = 0; pepar < 10; pepar++) { | ||
| let randomIndex = Math.floor(Math.random() * allLetters.length); |
There was a problem hiding this comment.
| let randomIndex = Math.floor(Math.random() * allLetters.length); | |
| const randomIndex = Math.floor(Math.random() * allLetters.length); |
| let winningWord = '' | ||
| let winningScore = 0 |
There was a problem hiding this comment.
| let winningWord = '' | |
| let winningScore = 0 | |
| let winningWord = ''; | |
| let winningScore = 0; |
While JavaScript's automatic semicolon insertion (ASI) will add a semicolon after line 4, our curriculum prefers to explicitly put them after every statement for clarity and to avoid potential issues. This can be team dependent so if you're working on JS, check in with your teammates to see how they do it.
| } else if (winningScore < score) { | ||
| winningScore = score | ||
| winningWord = word | ||
|
|
||
| } |
There was a problem hiding this comment.
| } else if (winningScore < score) { | |
| winningScore = score | |
| winningWord = word | |
| } | |
| } else if (winningScore < score) { | |
| winningScore = score; | |
| winningWord = word; | |
| } |
Remove unnecessary blank line and add semicolons
|
|
||
| } | ||
| } | ||
| return {word: winningWord, score: winningScore} |
There was a problem hiding this comment.
| return {word: winningWord, score: winningScore} | |
| return {word: winningWord, score: winningScore}; |
| expectScores({ | ||
| "":0 | ||
| }); |
There was a problem hiding this comment.
When breaking up an object on multiple lines, we should add indentation to make it easier to read.
| expectScores({ | |
| "":0 | |
| }); | |
| expectScores({ | |
| "": 0 | |
| }); |
Or you could do it one line expectScores({"": 0});
| for (let word of words) { | ||
| let score = scoreWord(word) | ||
| if (winningScore === score) { | ||
| if (word.length === 10 && winningWord.length !== 10) { |
There was a problem hiding this comment.
Consider using a constant variable to reference the integer 10 to make your code more self documenting.
Maybe like TIE_BREAK_LENGTH.
| if (word.length === 10 && winningWord.length !== 10) { | |
| if (word.length === TIE_BREAK_LENGTH && winningWord.length !== TIE_BREAK_LENGTH) { |
No description provided.