Last active
March 24, 2020 08:08
-
-
Save nkitku/53d4f1352f7d4e4b021f54f5dc768cfe to your computer and use it in GitHub Desktop.
Up To 102 digit Number to Word Smallest Code in Javascript ES6
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
nw=((e,n="Eigh",t=e=>e.split(/(?=[A-Z])|,/),i=(e,n)=>e.map(e=>e+n),r=t(`,OneTwoThreeFourFiveSixSevenEightNine`),o=["",,...i(["Twen",e="Thir","For",...n=["Fif",r[6],r[7],n,r[9]]],"ty")],u=["Ten","Eleven","Tweleve",...i([e,r[4],...n],"teen")],T=[n="","Thousand ",...i([...t("MBTrQuadrQuintSextSeptOctNonDec"),...i(e=t("UnDuoTreQuattuorQuinSexSeptenOctoNovem"),"dec"),...i(["V",...i(e,"v"),"Tr","Untr","Duotr"],"igint")],"illion ")])=>(i,l=(i+=n).length,d=0)=>[...i].reduce((v,S,c)=>(e=l-c,v+=(e+1)%3?(t=d?(d=0,u[S]):r[S],t&&t+" ")+((e+2)%3&&+S?"Hundred ":n):1==S?(d=1,n):o[S]&&o[S]+" ",v+=T[(t=e-1)%3==0?(+i[c-2]||+i[c-1]||+S)&&t/3:0]),n).trim()||"Zero")(); |
Author
nkitku
commented
Mar 24, 2020
•
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment