Skip to content

Comments

Atakan Temizkan#223

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

Atakan Temizkan#223
AtikoSpeed wants to merge 3 commits intoboolean-uk:mainfrom
AtikoSpeed:main

Conversation

@AtikoSpeed
Copy link

No description provided.

function scrabble() {
// write code here
function checkIncorrect(letterArray) {
const allowedChars = [
Copy link
Contributor

Choose a reason for hiding this comment

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

better put this outside function since its const and read only:

SCABBLE_LETTERS or similar would be better name

@@ -1,5 +1,150 @@
function scrabble() {
// write code here
function checkIncorrect(letterArray) {
Copy link
Contributor

Choose a reason for hiding this comment

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

checkIncorrect is bad name doesn't tell me what it is going to check for / what it is goign to return, pick a better name

@@ -1,5 +1,150 @@
function scrabble() {
// write code here
function checkIncorrect(letterArray) {
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 usually called character array not letter array

}
}

function specialCases(letterArray) {
Copy link
Contributor

Choose a reason for hiding this comment

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

again, bad function name, special cases doesn't tell me what this function is meant to do


for (let i = 0; i < letterArray.length; i++) {
let currentLetterScore = 0
if (onePointers.includes(letterArray[i])) {
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 a lot of code repetition, if you had represented the letters and scores as a dictionary, you could have done this in 3 lines of code:

const LETTER_SCORES = {
  a: 1,
  b: 2,
  etc..
}

// score:
const score = LETTER_SCORES[letter]

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