-
-
Save AliceWonderland/c4e4354ce2936df66a15eaeb93016ac3 to your computer and use it in GitHub Desktop.
2.4 Bactrian Camel Case created by smillaraaq - https://repl.it/GvLL/5
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 bactrianCase(message){ | |
var resultMessage=""; | |
for(i=0;i<message.length;i++){ | |
if(i%2===0){ | |
resultMessage+=message[i].toUpperCase(); | |
}else{ | |
resultMessage+=message[i].toLowerCase(); | |
} | |
//(i%2===0) ? resultMessage+=message[i].toUpperCase() : resultMessage+=message[i].toLowerCase(); | |
} | |
console.log(resultMessage); | |
} | |
bactrianCase("thisisatest"); | |
function bactrianCase2(message){ | |
var isPreviousLetterCaps=false; | |
var resultMessage=""; | |
for(i=0;i<message.length;i++){ | |
if(isPreviousLetterCaps){ | |
resultMessage+=message[i].toLowerCase(); | |
isPreviousLetterCaps=false; | |
}else{ | |
resultMessage+=message[i].toUpperCase(); | |
isPreviousLetterCaps=true; | |
} | |
} | |
console.log(resultMessage); | |
} | |
//bactrianCase2("thisisatest"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment