I am a software development engineer in test for Infosys. My job is officially to write automated tests in Selenium Webdriver. I'm also a web developer as a hobbyest
A few days late, but here's my JavaScript solution, using reduce.
functionscoreWord(string){letword=string.toLowerCase();constscores={a:1,// ... etc, cut for concisenessz:10,q:10}letmultiplier=1;if(word.substring(word.length-1)==='2'){multiplier=2;word=word.substring(0,word.length-1);}elseif(word.substring(word.length-1)==='3'){multiplier=3;word=word.substring(0,word.length-1);}letbonus=word.split('').filter(char=>{return!['*','^'].includes(char);}).length>=7?50:0;returnword.split('').reduce((score,letter,index,letters)=>{constnext=index+1<letters.length?letters[index+1]:null;if('abcdefghijklmnopqrstuvwxyz'.includes(letter)){if(next&&['*','^'].includes(next)){if(next==='^'){returnscore+=0;}if(next==='*'){if(index+2<letters.length&&letters[index+2]==='*'){score+=(scores[letter]*3);}else{score+=(scores[letter]*2);}returnscore;}}returnscore+=scores[letter];}else{returnscore;}},0)*multiplier+bonus;}
I changed the rules a bit, since it's hard to distinguish between double/triple words and words that naturally end in d or t, I decided to use 2 or 3 instead.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
A few days late, but here's my JavaScript solution, using
reduce
.I changed the rules a bit, since it's hard to distinguish between double/triple words and words that naturally end in d or t, I decided to use 2 or 3 instead.