Last active
April 5, 2023 14:44
-
-
Save DevGW/757962322c230041b8af7a87ab12f0d0 to your computer and use it in GitHub Desktop.
Javascript :: alternating character Caps example #js
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 crazyCaps(originalString) { | |
let crazyString = ''; | |
for (let i = 0; i < originalString.length; i++) { | |
let char = originalString[i]; | |
if (i % 2 === 0) { | |
crazyString += char; | |
} else { | |
char = char.toUpperCase(); | |
crazyString += char; | |
} | |
} return crazyString; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment