Earth - Denise - JS Adagrams#44
Open
dnsrocha wants to merge 11 commits into
Open
Conversation
spitsfire
reviewed
Dec 18, 2020
Comment on lines
+12
to
+13
| let randIndex = Math.floor(Math.random() * letterPool.length); | ||
| let randLetter = letterPool.slice(randIndex, randIndex + 1); |
There was a problem hiding this comment.
we can change these to const because the variables itself if being assigned once EVERY iteration. This means it's not being re-assigned.
spitsfire
reviewed
Dec 18, 2020
| for(const letter of input) { | ||
| if (tally[letter] && tally[letter] > 0) { | ||
| tally[letter] -= 1; | ||
| let handCopy = Array.from(lettersInHand); |
There was a problem hiding this comment.
same here.... this can be const. Arrays and objects remain arrays and objects even when we add keys or values to them.
spitsfire
reviewed
Dec 18, 2020
Comment on lines
+57
to
+65
| let maxScore = Math.max(...words.map(word => this.scoreWord(word))); // find the maximum score from all the words | ||
| let highScoreArr = words.filter(word => this.scoreWord(word) === maxScore); // find the words that has the maximum score | ||
|
|
||
| if (highScoreArray.length > 1) { | ||
| bestWord = this.tieBreaker(highScoreArray); | ||
| } else { | ||
| bestWord = highScoreArray[0]; | ||
| }; | ||
| if (highScoreArr.length === 1) { | ||
| return {word: highScoreArr[0], score: maxScore}; | ||
| } | ||
|
|
||
| return bestWord; | ||
| let minLength = Math.min(...highScoreArr.map(word => word.length == 10 ? 0 : word.length)); | ||
| let shortestWords = highScoreArr.filter(word => (word.length == 10 ? 0 : word.length) === minLength); |
There was a problem hiding this comment.
these variables can be const as well
spitsfire
reviewed
Dec 18, 2020
spitsfire
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. |
✔️ Couple of variables could be changed to const. See comments for details |
| 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
| Overall Feedback | Criteria | yes/no |
|---|---|---|
| Green (Meets/Exceeds Standards) | 5+ in Code Review && 3+ in Functional Requirements | ✔️ |
| Yellow (Approaches Standards) | 4+ in Code Review && 2+ in Functional Requirements, or the instructor judges that this project needs special attention | |
| Red (Not at Standard) | 0-3 in Code Review or 0,1 in Functional Reqs, or assignment is breaking/doesn’t run with less than 5 minutes of debugging, or the instructor judges that this project needs special attention |
Code Style Bonus Awards
Was the code particularly impressive in code style for any of these reasons (or more...?)
| Quality | Yes? |
|---|---|
| Perfect Indentation | ✅ |
| Descriptive/Readable | ✅ |
| Logical/Organized | ✅ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Assignment Submission: JS Adagrams
Congratulations! You're submitting your assignment. Please reflect on the assignment with these questions.
Reflection