Last active
August 29, 2015 13:59
-
-
Save rvbsanjose/10708098 to your computer and use it in GitHub Desktop.
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
// Using the JavaScript language, have the function SwapCase(str) take the str parameter and swap the case of each character. | |
// For example: if str is "Hello World" the output should be hELLO wORLD. Let numbers and symbols stay the way they are. | |
// Input = "Hello-LOL" Output = "hELLO-lol" | |
// Input = "Sup DUDE!!?" Output = "sUP dude!!?" | |
function SwapCase( str ) { | |
var swap = ''; | |
for ( var i = 0; i < str.length; i++ ) { | |
if ( str[i] == str[i].toUpperCase() ) | |
swap += str[i].toLowerCase(); | |
else | |
swap += str[i].toUpperCase(); | |
} | |
return swap; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment