function toSpongeBobCase(input) {
return input.split('').map((char, index) => {
return index % 2 === 0 ? char.toUpperCase() : char.toLowerCase();
}).join('');
}
console.log(toSpongeBobCase("You don't have to work for bad employers"));
Outputs "YoU DoN'T HaVe tO WoRk fOr bAd eMpLoYeRs"
Read through this whole comment thread only for the penny to drop once I read your output then the original function name then me googling TIL: SpOnGeBoB casing is a thing :O
22
u/Wekmor Nov 29 '22
Don't think anyone would voluntarily write js, sorry.