this post was submitted on 13 Dec 2025
371 points (97.9% liked)

Programmer Humor

27836 readers
1093 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 2 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
[–] OshaqHennessey@midwest.social 28 points 7 hours ago (2 children)
function myFunction() {
  try {
    x = new Random().nextInt();
    if (x != 10) {
     throw "not 10";
    }
    else {
      return (10)
    }
    catch(err) {
      myFunction()
    }
  }
}

x = myFunction()

Commit notes: Added error handling

[–] firewallfail@lemmy.world 20 points 6 hours ago (1 children)

Returning 10 instead of x when x finally ends up being 10 really ties it together.

[–] OshaqHennessey@midwest.social 9 points 6 hours ago

I'm glad you noticed. That was my favorite part too.

[–] NikkiDimes@lemmy.world 1 points 6 hours ago (1 children)

SyntaxError: Unexpected token 'catch'

[–] OshaqHennessey@midwest.social 2 points 4 hours ago

Coding on mobile is hard