Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <cfscript>
- writeDump(score("food"));
- function score( word ) {
- //keep tally of points
- var count=0;
- var wordArray=[];
- for ( var i=0; i<word.length(); i++ ){
- arrayAppend( wordArray, word.charAt(i)
- );
- }
- writeDump(wordArray);
- for ( letter in wordArray ){
- if ( ListContains( ['A', 'E', 'I', 'O', 'U', 'L', 'N', 'R', 'S', 'T'], letter ) ){
- count+=1;
- }
- if ( ListContains( ['D', 'G'], letter ) ){
- count+=2;
- }
- if ( ListContains( ['B', 'C', 'M', 'P'], letter ) ){
- count+=3;
- }
- if ( ListContains( ['F', 'H', 'V', 'W', 'Y'], letter ) ){
- count+=4;
- }
- if ( ListContains( ['K'], letter ) ){
- count+=5;
- }
- if ( ListContains( ['J', 'X'], letter ) ){
- count+=8;
- }
- if ( ListContains( ['Q', 'Z'], letter ) ){
- count+=10;
- }
- }
- return count;
- }
- </cfscript>
Add Comment
Please, Sign In to add comment