Here's mine -- I'll admit that it took a little to recognize that the index was supposed to be word-based, not for the entire string. But that's what test cases are for! :-)
const TRANSFORMER = { LOWER: String.prototype.toLowerCase, UPPER: String.prototype.toUpperCase }; const transform = (v, which) => which.apply(v); const weirdCase = str => str.split(" ") .map((part) => Array.from(part) .map((ch, idx) => transform(ch, idx & 1 ? TRANSFORMER.LOWER : TRANSFORMER.UPPER )) .join("")) .join(" ");
Gist: gist.github.com/kerrishotts/e3a213...
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Here's mine -- I'll admit that it took a little to recognize that the index was supposed to be word-based, not for the entire string. But that's what test cases are for! :-)
Gist: gist.github.com/kerrishotts/e3a213...