We're a place where coders share, stay up-to-date and grow their careers.
I've implemented based off of La blatte's answer.
const caser = { 0: c => c.toUpperCase(), 1: c => c.toLowerCase() } const mod = i => i % 2 const weirdCase = text => text.split(' ').map(word => [...word].map((c, i) => caser[mod(i)](c)).join('') ).join(' ') console.log(["String", "Weird string case"].map(weirdCase))
prints,
["StRiNg", "WeIrD StRiNg CaSe"]
I've implemented based off of La blatte's answer.
prints,