Skip to content

Instantly share code, notes, and snippets.

@marlonlom
Last active November 6, 2020 20:08
Show Gist options
  • Save marlonlom/99d6f95020a9a44d06509dc6dbf7cbe8 to your computer and use it in GitHub Desktop.
Save marlonlom/99d6f95020a9a44d06509dc6dbf7cbe8 to your computer and use it in GitHub Desktop.
Simple Javascript function for Japanese name generator
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]);
}
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