Pheonix class: Madeline Bennett#31
Conversation
…sts: "draws ten letters from pool ", "returns an array, and each is a single letter str", "does not draw a letter too many times".
…d helper function that turns arrays into an occurence dictionary. all tests pass from part one and part two.
…logic tests and was succesfull.
anselrognlie
left a comment
There was a problem hiding this comment.
Looks good overall! Please review my comments, and let me know if you have any questions.
| "version": "0.2.0", | ||
| "resolved": "https://registry.npmjs.org/@eslint/plugin-kit/-/plugin-kit-0.2.0.tgz", | ||
| "integrity": "sha512-vH9PiIMMwvhCx31Af3HiGzsVNULDbyVkHXwlemn/B0TFj/00ho3y55efXrUZTfQipxoHC5u4xq6zblww1zm1Ig==", | ||
| "version": "0.2.3", |
There was a problem hiding this comment.
Any idea what caused these changes in the lock file? Not a problem that they were, but with a typical project setup, this file wouldn't have been modified.
| expectScores({ | ||
| '': 0 | ||
| }); |
| }); | ||
|
|
||
| describe.skip("highestScoreFrom", () => { | ||
| describe("highestScoreFrom", () => { |
| const correct = { word: "XXXX", score: scoreWord("XXXX") }; | ||
|
|
||
| throw "Complete test by adding an assertion"; | ||
| expect(highestScoreFrom(words)).toEqual(correct); |
| @@ -1,15 +1,166 @@ | |||
| export const drawLetters = () => { | |||
| // Implement this method for wave 1 | |||
| const letterPool = { | |||
There was a problem hiding this comment.
Consider moving the dictionary of letters to be a global constant. This is pretty common to do with large data values, so that the body of the function isn't dominated with just the data, which we have to scroll past to find the actual logic. Also, while it would only be a small cost, JS does recreate the dictionary over and over each time drawLetters is called, whereas if we move it outside the function, it will be initialized only once.
|
|
||
| //// helper functions/////// | ||
|
|
||
| const arrayToOccurenceDict = (array) => { |
There was a problem hiding this comment.
Nice helper to build a frequency map from something iterable.
| return occurenceDictionary | ||
| } | ||
|
|
||
| const getRandomInt = (min, max) => { |
There was a problem hiding this comment.
👀 Because the previous closing brace was improperly indented, that's thrown off the formatting of everything that follows.
| //6 points: | ||
| 'J' : 8, 'X' : 8, | ||
| //7 points: |
| //1 point | ||
| 'A' : 1, 'E' : 1, 'I' : 1, 'O' : 1 , 'U' : 1, 'L' : 1, 'N' : 1, 'R' : 1, 'S' : 1, 'T' : 1, | ||
| //2 points | ||
| 'D' : 2, 'G' : 2, | ||
| //3 points | ||
| 'B' : 3, 'C' : 3, 'M' : 3, 'P' : 3, | ||
| //4 points: | ||
| 'F' : 4, 'H' : 4, 'V' : 4, 'W' : 4, 'Y': 4, | ||
| //5 points: | ||
| 'K' : 5, | ||
| //6 points: | ||
| 'J' : 8, 'X' : 8, | ||
| //7 points: | ||
| 'Q' : 10, 'Z' : 10 |
There was a problem hiding this comment.
Since JS won't care what order the letters are listed, prefer listing them in a way that's easier for humans to check that everything is present and accounted for. Writing the letters alphabetically would make it easier for the reader to confirm that all letters are listed with no gaps.
| if (isNaN(lettersAndValues[key])){ | ||
| return letterOccurenceDict[key] | ||
| } |
There was a problem hiding this comment.
This is puzzling to me. My interpretation of the intent is that if the specified letter doesn't appear in the score data, that it will use the number of occurrences as the score. Why would an "unscored" letter be worth any score?
We didn't have any test cases where you would receive an unscored letter, but if I were in that situation, I would either ignore the invalid letter (give it a 0 score), or raise some sort of error.
No description provided.