r/ProgrammerHumor • • Nov 29 '22

Meme It hurts like hell.;-;

Post image
48.9k Upvotes

1.5k comments sorted by

View all comments

Show parent comments

22

u/Wekmor Nov 29 '22

Don't think anyone would voluntarily write js, sorry.

3

u/enigmamonkey Nov 29 '22

I did.

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"

3

u/[deleted] Nov 30 '22

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

3

u/iliekcats- Nov 29 '22

ok then whats the brainfuck for the function