Last active
January 4, 2016 04:08
-
-
Save jorinvo/8566064 to your computer and use it in GitHub Desktop.
some string fun
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
function alphabetSoup(str) { | |
return str.split(' ').map(function(word) { | |
var parts = word.substr(1,word.length-2).split('') | |
.sort(function(){ return Math.random(); }) | |
.join(''); | |
return word[0] + parts + word[word.length-1]; | |
}).join(' '); | |
} | |
function rollercaster(str) { | |
return str.split('').map(function(char, i) { | |
return i%2 ? char.toLowerCase() : char.toUpperCase(); | |
}).join(''); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment