Skip to content

Instantly share code, notes, and snippets.

@DevGW
Last active April 5, 2023 14:44
Show Gist options
  • Save DevGW/757962322c230041b8af7a87ab12f0d0 to your computer and use it in GitHub Desktop.
Save DevGW/757962322c230041b8af7a87ab12f0d0 to your computer and use it in GitHub Desktop.
Javascript :: alternating character Caps example #js
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