Skip to content

Instantly share code, notes, and snippets.

@jluismm2311
Created September 7, 2015 22:19
Show Gist options
  • Save jluismm2311/7d99664027319a0380dd to your computer and use it in GitHub Desktop.
Save jluismm2311/7d99664027319a0380dd to your computer and use it in GitHub Desktop.
Scrabble Score
function scrabbleScore(str){
var value = 0;
for(i = 0 ; i< str.length; i++){
switch (true){
case( /[dg]/i.test(str[i])):
value += 2;
break;
case( /[bcmp]/i.test(str[i])):
value += 3;
break;
case( /[fhvwy]/i.test(str[i])):
value += 4;
break;
case( /[k]/i.test(str[i])):
value += 5;
break;
case( /[jx]/i.test(str[i])):
value += 8;
break;
case( /[qz]/i.test(str[i])):
value += 10;
break;
case( /[aeioulnrst]/i.test(str[i])):
value += 1;
break;
}
}
return value;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment