Last active
November 6, 2020 20:08
-
-
Save marlonlom/99d6f95020a9a44d06509dc6dbf7cbe8 to your computer and use it in GitHub Desktop.
Simple Javascript function for Japanese name generator
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
const japaneseName= (name) => { | |
const dictionary = {"a": "ka","b": "tu","c": "mi","d": "te","e": "ku","f": "lu","g": "ji","h": "ri","i": "ki","j": "zu","k": "me","l": "ta","m": "rin","n": "to","o": "mo","p": "no","q": "ke","r": "shi","s": "ari","t": "chi","u": "do","v": "ru","w": "na","x": "mei","y": "fu","z": "ra"}; | |
return name.substring(0, name.indexOf(' ') >=0 ? name.indexOf(' ') : name.length).replace(/[a-z]/gi, m => dictionary[m]); | |
} |
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
const japaneseName=a=>{const b={a:"ka",b:"tu",c:"mi",d:"te",e:"ku",f:"lu",g:"ji",h:"ri",i:"ki",j:"zu",k:"me",l:"ta",m:"rin",n:"to",o:"mo",p:"no",q:"ke",r:"shi",s:"ari",t:"chi",u:"do",v:"ru",w:"na",x:"mei",y:"fu",z:"ra"};return a.substring(0,0<=a.indexOf(" ")?a.indexOf(" "):a.length).replace(/[a-z]/gi,a=>b[a])}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment