Richelle (water)#38
Conversation
beccaelenzil
left a comment
There was a problem hiding this comment.
JS Adagrams
Major Learning Goals/Code Review
| Criteria | yes/no, and optionally any details/lines of code to reference |
|---|---|
Correctly uses variables, and only uses const and let variables. The program prefers const variables. The program never uses var. |
✔️ |
| Practices best-practices in JavaScript syntax. There are semi-colons at the end of most lines that need semi-colons. Variables and functions are named with camelCase. | ✔️ |
| Correctly creates and calls functions within an object with proper syntax (parameters, return statements, etc.) | ✔️ |
| Uses correct syntax for conditional logic and iteration | ✔️ |
| Practices git with at least 3 small commits and meaningful commit messages | ✔️ |
Utilizes unit tests to verify code; tests can run using the command $ npm test test/adagrams.test.js and we see test successes and/or failures |
✔️ |
Functional Requirements
| Functional Requirement | yes/no |
|---|---|
For the drawLetters function, there is an appropriate data structure to store the letter distribution. (You are more likely to draw an 'E' than an 'X'.) |
✔️ |
Utilizes unit tests to verify code; all tests for drawLetters and usesAvailableLetters pass |
✔️ |
Utilizes unit tests to verify code; all tests for scoreWord pass |
✔️ |
Utilizes unit tests to verify code; all tests for highestScoreFrom pass |
✔️ |
Overall Feedback
Great work on this project! In this project you’ve taken some interesting logic and worked it into JavaScript syntax. Your code is clear and readable. I've left a few in-line comments on ways you might consider refactoring. Please let me know if you have any questions. Keep up the hard work!
| Overall Feedback | Criteria | yes/no |
|---|---|---|
| Green (Meets/Exceeds Standards) | 5+ in Code Review && 3+ in Functional Requirements | ✔️ |
Code Style Bonus Awards
Was the code particularly impressive in code style for any of these reasons (or more...?)
| Quality | Yes? |
|---|---|
| Perfect Indentation | ✅ |
| Elegant/Clever | ✅ |
| Descriptive/Readable | ✅ |
| Concise | ✅ |
| Logical/Organized | ✅ |
| const Adagrams = { | ||
| drawLetters() { | ||
| // Implement this method for wave 1 | ||
| const letterQuantity = {"A": 9, "B": 2, "C": 2, "D": 4, "E": 12, "F": 2, "G": 3, "H": 2, "I": 9, "J": 1, "K": 1, "L": 4, "M": 2, "N": 6, "O": 8, "P": 2, "Q": 1, "R": 6, "S": 4, "T": 2, "U": 4, "V": 2, "W": 2, "X": 1, "Y": 2, "Z": 1}; |
There was a problem hiding this comment.
Consider moving each letter to its own line to increase readability and changeability.
| const times = x => f => { | ||
| if (x > 0) { | ||
| f(); | ||
| times (x - 1) (f); |
There was a problem hiding this comment.
Minor note: remove space between function and arguments to increase readability.
| times (x - 1) (f); | |
| times(x - 1) (f); |
| scoreWord(word) { | ||
| let score = 0; | ||
|
|
||
| for (const letter of word) { |
There was a problem hiding this comment.
Consider how storing each letter score in an object and using that value to update the score could DRY up this code.
| let highestScorer = scores[0]; | ||
| for (let item of scores) { | ||
| if (item['score'] > highestScorer['score']) { | ||
| highestScorer = item; | ||
| } | ||
| } | ||
|
|
||
| let ties = [] | ||
| for (let item of scores) { | ||
| if (item['score'] === highestScorer['score']) { | ||
| ties.push(item); | ||
| } | ||
| } | ||
|
|
||
| let winner = ties.find(word => word['word'].length == 10 ) // finds the fir st word with ten letters | ||
|
|
||
| if (winner) { | ||
| return winner; | ||
| } else { // find the word with min length | ||
| winner = ties[0] | ||
| for (let item of ties) { | ||
| if (item['word'].length < winner.word.length) { | ||
| winner = item | ||
| } | ||
| } |
There was a problem hiding this comment.
There are 3 loops that might run in this function. Consider how you could refactor to include the logic of tie-breaking as you go through the original loop.
Assignment Submission: JS Adagrams
Congratulations! You're submitting your assignment. Please reflect on the assignment with these questions.
Reflection