Last active
February 20, 2019 18:46
-
-
Save TroublesNCuddles/9e44930d4075587a1bd27e7a6aa3fc59 to your computer and use it in GitHub Desktop.
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
const isRegularCharacter = char => { | |
const code = char.charCodeAt(0); | |
return (code > 64 && code < 91) || (code > 96 && code < 123); | |
}; | |
const mock = (str) => { | |
let count = 0; | |
return str | |
.split("") | |
.map(char => { | |
if (!isRegularCharacter(char)) { | |
return char; | |
} | |
return count++ % 2 === 0 ? char.toUpperCase() : char.toLowerCase(); | |
}) | |
.join(""); | |
}; | |
process.stdout.end(mock(process.argv.slice(2).join(" "))); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment