Created
January 19, 2015 12:53
-
-
Save azs06/ea458e0373564ba13eff to your computer and use it in GitHub Desktop.
// source http://jsbin.com/gapocazave
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<script id="jsbin-javascript"> | |
var name = "Sebastian STIAN THRUN"; | |
function nameChanger(oldName) { | |
var finalName = oldName; | |
// Your code goes here! | |
var fidx = finalName.indexOf(' '); | |
var lidx = finalName.lastIndexOf(' '); | |
var fname = finalName.slice(0,fidx); | |
var npos = lidx+1; | |
var lname = finalName.slice(npos); | |
fname = fname.toLowerCase(); | |
fname = fname.charAt(0).toUpperCase()+fname.slice(1); | |
console.log(fname); | |
lname = lname.toUpperCase(); | |
console.log(lname); | |
finalName = fname+" "+lname; | |
// Don't delete this line! | |
return finalName; | |
} | |
// Did your code work? The line below will tell you! | |
console.log(nameChanger(name)); | |
</script> | |
<script id="jsbin-source-javascript" type="text/javascript">var name = "Sebastian STIAN THRUN"; | |
function nameChanger(oldName) { | |
var finalName = oldName; | |
// Your code goes here! | |
var fidx = finalName.indexOf(' '); | |
var lidx = finalName.lastIndexOf(' '); | |
var fname = finalName.slice(0,fidx); | |
var npos = lidx+1; | |
var lname = finalName.slice(npos); | |
fname = fname.toLowerCase(); | |
fname = fname.charAt(0).toUpperCase()+fname.slice(1); | |
console.log(fname); | |
lname = lname.toUpperCase(); | |
console.log(lname); | |
finalName = fname+" "+lname; | |
// Don't delete this line! | |
return finalName; | |
} | |
// Did your code work? The line below will tell you! | |
console.log(nameChanger(name));</script></body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var name = "Sebastian STIAN THRUN"; | |
function nameChanger(oldName) { | |
var finalName = oldName; | |
// Your code goes here! | |
var fidx = finalName.indexOf(' '); | |
var lidx = finalName.lastIndexOf(' '); | |
var fname = finalName.slice(0,fidx); | |
var npos = lidx+1; | |
var lname = finalName.slice(npos); | |
fname = fname.toLowerCase(); | |
fname = fname.charAt(0).toUpperCase()+fname.slice(1); | |
console.log(fname); | |
lname = lname.toUpperCase(); | |
console.log(lname); | |
finalName = fname+" "+lname; | |
// Don't delete this line! | |
return finalName; | |
} | |
// Did your code work? The line below will tell you! | |
console.log(nameChanger(name)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment