Created
April 6, 2017 04:34
-
-
Save anonymous/c2712d0a7e513a7513ff7f105b9c0d72 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