Skip to content

Instantly share code, notes, and snippets.

@macikokoro
Created June 15, 2014 19:15
Show Gist options
  • Save macikokoro/ce4b7458091e7251c257 to your computer and use it in GitHub Desktop.
Save macikokoro/ce4b7458091e7251c257 to your computer and use it in GitHub Desktop.
A cool way to use substrings to capitalize the first letter of a name.
var fullName = "";
var name;
var firstLetter;
var fixName = function () {
}
name = prompt("Enter your first name (all in lower case):");
firstLetter = name.substring(0, 1);
name = firstLetter.toUpperCase() + name.substring(1);
fullName = fullName + " " + name;
name = prompt("Enter your second name (all in lower case):");
firstLetter = name.substring(0, 1);
name = firstLetter.toUpperCase() + name.substring(1);
fullName = fullName + " " + name;
console.log("And your full name is:" + fullName);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment