Skip to content

Instantly share code, notes, and snippets.

@etoxin
Created November 19, 2019 05:22
Show Gist options
  • Save etoxin/e24a711a40f5289367e06d471f4992eb to your computer and use it in GitHub Desktop.
Save etoxin/e24a711a40f5289367e06d471f4992eb to your computer and use it in GitHub Desktop.
CodeWars
let p =
"The quick brown fox jumps over the lazy dog. If the dog reacted, was it really lazy?";
function toWeirdCase(InputString) {
return InputString.split("")
.filter(l => l.match(/[a-zA-Z]/))
.map((l, i) => (i % 2 ? l.toLowerCase() : l.toUpperCase()))
.join("");
}
console.log(toWeirdCase(p));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment