Open
Conversation
dogezen
reviewed
May 1, 2024
src/scrabble.js
Outdated
|
|
||
| function scrabble(word) { | ||
| // write code here | ||
| if (word == null){ |
|
|
||
| for (let i = 0; i < word.length; i++){ | ||
| const char = word[i]; | ||
|
|
Contributor
There was a problem hiding this comment.
there are no comments in your code, it's very hard to understand and follow the logic, takes too much effort; suggest adding comments explaining what your code is doing
src/scrabble.js
Outdated
| return 0; | ||
| } | ||
| let score = 0; | ||
| let wordMultiplier =1; |
src/scrabble.js
Outdated
| i++; | ||
| const letter = word[i]; | ||
| if (!letter) break; | ||
| score += (letterValues[letter.toUpperCase()] || 0) * modifier; |
Contributor
There was a problem hiding this comment.
this is quite hard to understand what it does
Contributor
There was a problem hiding this comment.
add some comments explaining it
| if (char === '{' || char === '[') { | ||
| let endChar = char === '{' ? '}': ']'; | ||
| let modifier = char === '{'? 2 : 3; | ||
| i++; |
Contributor
There was a problem hiding this comment.
unclear why you are skipping forwards, some comments might help
src/scrabble.js
Outdated
| let modifier = char === '{'? 2 : 3; | ||
| i++; | ||
| const letter = word[i]; | ||
| if (!letter) break; |
Contributor
There was a problem hiding this comment.
unclear why you'd break - comments to explain this
src/scrabble.js
Outdated
| if (!letter) break; | ||
| score += (letterValues[letter.toUpperCase()] || 0) * modifier; | ||
| i++; | ||
| while (i < word.length && word[i] !== endChar) |
Contributor
There was a problem hiding this comment.
same here, unclear what this does - some comments would help
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.
No description provided.