Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
alternate casing
function alternateCasing(text){
let letters ''
for (const index in text) {
if(index % 2) {
letters += text[index].toLowerCase()
} else {
letters += text[index].toUpperCase()
}
}
}
function alternateCasing(text) {
return text
.split('')
.map((char, i) => 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