Skip to content

Instantly share code, notes, and snippets.

Created April 6, 2017 04:34
Show Gist options
  • Save anonymous/5219d0416b3dabd5a59880b45c3349a2 to your computer and use it in GitHub Desktop.
Save anonymous/5219d0416b3dabd5a59880b45c3349a2 to your computer and use it in GitHub Desktop.
2.3 Nickname Generator created by smillaraaq - https://repl.it/GvJF/3
function nicknameGenerator(fullName){
var nickName="";
var fullNameTemp=fullName.toLowerCase();
if(fullNameTemp[2]==="a" ||
fullNameTemp[2]==="e" ||
fullNameTemp[2]==="i" ||
fullNameTemp[2]==="o" ||
fullNameTemp[2]==="u"){
//log 4 letters
nickName=fullName.slice(0,4);
}else{
//log 3 letters
nickName=fullName.slice(0,3);
}
console.log("The nickname for " +fullName+ " is '" + nickName + "'.");
return nickName;
}
nicknameGenerator("ALICE");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment