Skip to content

Instantly share code, notes, and snippets.

@caferrari
Last active January 4, 2016 06:19
Show Gist options
  • Save caferrari/8581222 to your computer and use it in GitHub Desktop.
Save caferrari/8581222 to your computer and use it in GitHub Desktop.
'use strict';
var Translator = function() {
this.dict = 'ka,tu,mi,te,ku,lu,ji,ri,ki,zu,me,ta,rin,to,mo,no,ke,shi,ari,chi,do,ru,na,mei,fu,ra'.split(',');
};
Translator.prototype.parse = function(str) {
var that = this;
return str.split('').reduce(function(r, c) {
var chr = c.toLowerCase().charCodeAt(0) - 97;
return r + (that.dict[chr] || ' ');
}, '');
}
if (process.argv.length != 3) {
console.log('Use: node japaname.js yourname');
process.exit();
}
console.log((new Translator()).parse(process.argv[2]));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment