Skip to content

Comments

Scrabble#219

Open
gent009 wants to merge 3 commits intoboolean-uk:mainfrom
gent009:main
Open

Scrabble#219
gent009 wants to merge 3 commits intoboolean-uk:mainfrom
gent009:main

Conversation

@gent009
Copy link

@gent009 gent009 commented May 1, 2024

No description provided.

src/scrabble.js Outdated

function scrabble(word) {
// write code here
if (word == null){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use === not ==


for (let i = 0; i < word.length; i++){
const char = word[i];

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

formatting

src/scrabble.js Outdated
i++;
const letter = word[i];
if (!letter) break;
score += (letterValues[letter.toUpperCase()] || 0) * modifier;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is quite hard to understand what it does

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add some comments explaining it

if (char === '{' || char === '[') {
let endChar = char === '{' ? '}': ']';
let modifier = char === '{'? 2 : 3;
i++;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here, unclear what this does - some comments would help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants