Shari Scrabble - #17
Conversation
…ut it is way too hard in js so I am erasing everything and pretending that it never happened
| var num = Object.keys(Scrabble.scoreChart); | ||
| var letters = Object.values(Scrabble.scoreChart); | ||
| for (i = 0; i < upWord.length; i++) { | ||
| for (d = 0; d < num.length; d ++){ |
There was a problem hiding this comment.
We generally use i, j, k for the iteration variable.
| var upWord = word.toUpperCase(); | ||
| var num = Object.keys(Scrabble.scoreChart); | ||
| var letters = Object.values(Scrabble.scoreChart); | ||
| for (i = 0; i < upWord.length; i++) { |
There was a problem hiding this comment.
Because you don't have the var in front of these iteration variables, each of these loops are creating global variables
| } | ||
| } | ||
| } | ||
| if (word.length >= 7){ |
There was a problem hiding this comment.
I might argue that greater than 7 would be an error not a bonus
| }); | ||
| for (var i = 0; i < scores.length; i++){ | ||
| if (scores[i] === max){ | ||
| if( (words[i].length === 7 && words[i] > maxWord) || ( words[i].length < maxWord.length && maxWord.length !== 7)){ |
There was a problem hiding this comment.
This line would be a great place to add a comment
| this.finalScore = 0; | ||
| }; | ||
|
|
||
| function add(a, b) { |
There was a problem hiding this comment.
Is this left over as a test from something else?
There was a problem hiding this comment.
Ohhh -- now I see how you're using this within the reduce logic
| else { | ||
| this.scores.push(Scrabble.score(words)); | ||
| this.totalScore(); | ||
| return Scrabble.score(words); |
There was a problem hiding this comment.
By calling score in here twice, you are doing the scoring logic twice which is unnecessary
I really enjoyed this exercise but was very stuck at the beginning. I think once I knew how to debug, re errors and somewhat figured out how variables and functions could interact, this made a bit more sense. I don't think my highest score logic in the scrabble object was the best (just like Scrabble OG) but it works. One thing I was happy about was being able to use an object for the score (scrabble tiles) and have the letters as arrays. In the original Scrabble, I was unable to figure the out and was happy with being able to figure out that logic this time around. If I had more time, I think I would have done TDD instead of just pushing through. I actually used my TDD examples to print out and test my scrabble methods.
I finished Wave II but was unable to move on to wave three.
Feedback on organization would be appreciated.