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.
swap case in java Coderbyte
swap case in javascript
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.
Explanation
I am going to be using a new string to store my modified results. I am going to loop thru every character and covert it to UpperCase. Then I am going to compare that to the character in the string. If they are the same - meaning both are uppercase then I am going to return the lowercase of the character. If they are not the same then return the Uppercase character.
Disclaimer: The above Problem is generated by Coderbyte but the Solution is provided by ShouterFolk.