Skip to content

Instantly share code, notes, and snippets.

@pgainda
Created May 8, 2013 16:06
Show Gist options
  • Save pgainda/5541522 to your computer and use it in GitHub Desktop.
Save pgainda/5541522 to your computer and use it in GitHub Desktop.
var name = "John Doe";
function getFirstName (fullName){
var i=0;
var firstName ="";
var next = fullName[0];
var length=fullName.length;
while(i<length && next!==" "){
firstName+=fullName[i];
i++;
next=fullName[i];
}
console.log( firstName);
}
getFirstName(name);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment