Skip to content

Instantly share code, notes, and snippets.

@SvizelPritula
Created April 21, 2020 11:36
Show Gist options
  • Save SvizelPritula/8b057583cc516f1dad1fed5620d4e63d to your computer and use it in GitHub Desktop.
Save SvizelPritula/8b057583cc516f1dad1fed5620d4e63d to your computer and use it in GitHub Desktop.
function scrabble(str) {
var score = 0;
for (var i = 0; i < str.length; i++) {
if (str[i] == 'a' || str[i] == 'A') {
score += 1;
} else {
if (str[i] == 'b' || str[i] == 'B') {
score += 3;
} else {
if (str[i] == 'c' || str[i] == 'C') {
score += 3;
} else {
if (str[i] == 'd' || str[i] == 'D') {
score += 2;
} else {
if (str[i] == 'e' || str[i] == 'E') {
score += 1;
} else {
if (str[i] == 'f' || str[i] == 'F') {
score += 4;
} else {
if (str[i] == 'g' || str[i] == 'G') {
score += 2;
} else {
if (str[i] == 'h' || str[i] == 'H') {
score += 4;
} else {
if (str[i] == 'i' || str[i] == 'I') {
score += 1;
} else {
if (str[i] == 'j' || str[i] == 'J') {
score += 8;
} else {
if (str[i] == 'k' || str[i] == 'K') {
score += 5;
} else {
if (str[i] == 'l' || str[i] == 'L') {
score += 1;
} else {
if (str[i] == 'm' || str[i] == 'M') {
score += 3;
} else {
if (str[i] == 'n' || str[i] == 'N') {
score += 1;
} else {
if (str[i] == 'o' || str[i] == 'O') {
score += 1;
} else {
if (str[i] == 'p' || str[i] == 'P') {
score += 3;
} else {
if (str[i] == 'q' || str[i] == 'Q') {
score += 10;
} else {
if (str[i] == 'r' || str[i] == 'R') {
score += 1;
} else {
if (str[i] == 's' || str[i] == 'S') {
score += 1;
} else {
if (str[i] == 't' || str[i] == 'T') {
score += 1;
} else {
if (str[i] == 'u' || str[i] == 'U') {
score += 1;
} else {
if (str[i] == 'v' || str[i] == 'V') {
score += 4;
} else {
if (str[i] == 'w' || str[i] == 'W') {
score += 4;
} else {
if (str[i] == 'x' || str[i] == 'X') {
score += 8;
} else {
if (str[i] == 'y' || str[i] == 'Y') {
score += 4;
} else {
if (str[i] == 'z' || str[i] == 'Z') {
score += 10;
} else {
if (str[i] == ' ') {
score += 0;
} else {
score += 0;
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
return score;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment