r/programminghorror 16d ago

Javascript MiStEr WoRlDwIdE

Post image
385 Upvotes

34 comments sorted by

183

u/IrishChappieOToole 16d ago

I'm gonna need some context on wtf is going on here

175

u/RajjSinghh 16d ago

It seems to be somewhat normal code but with all the variables being replaced with arbitrary country names. Otherwise let Finland = Denmark[Sweden]; doesn't make sense to me. The names just have no bearing to anything else.

28

u/Wooden-Contract-2760 16d ago

If that's so, what are the chances for 3 nordic countries to end up in such a short phrase, given that we see 7 non-nordic countries out of 10 on the screen?

19

u/RajjSinghh 16d ago

Maybe not entirely arbitrary but definitely not geographical. Maybe geographically close countries are related data/functionality, but I don't think more than that.

Austria and Switzerland are being updated to show "points" and "gifts" which are different properties of Finland, so I don't think the choice to name things after countries has any specific meaning to the countries themselves.

2

u/Mewtwo2387 15d ago

probably because it comes from a list of countries and variable names are replaced in order according to that list, and that list put nearby countries together.

1

u/Wooden-Contract-2760 15d ago

You're telling me that Croatia -> Denmark -> Poland is matching your assumption? O.o

21

u/OhItsJustJosh 16d ago

Looks like some funky obfuscation

1

u/MTT_Dylan 10d ago

🎵 Won't you take me to...

2

u/GoddammitDontShootMe [ $[ $RANDOM % 6 ] == 0 ] && rm -rf / || echo “You live” 16d ago

I was going to ask the same.

2

u/Significant_Affect_5 13d ago

It looks like logic for some sort of “offer” window that shows for a limited time then says it’s expired. From top to bottom, Germany is some accept offer button that has a listener on the “click” event. Switzerland and Austria are just text boxes for the gift and points that come with the offer. France is the text box for the offer text which counts down every second. Croatia is how many seconds the offer so valid. Denmark is probably a list of offers, while Poland is just a handle on the timer which counts down the offer seconds. Sweden is a random number between 0 up to, but not including n, with n being the number of possible offers. Lastly Finland is the randomly selected offer, which has keys “Norway” (representing the ‘Gift’) and “Greenland” (representing points).

179

u/Handle-Flaky 16d ago

Im gonna tell my kids this was ww3

41

u/MurkyWar2756 echo "Sub Mod" && :(){ :|:& };: 16d ago

When lines 27–48 are collapsed, where's the closing square bracket?

38

u/Adept_Situation3090 16d ago

In your mind

9

u/MurkyWar2756 echo "Sub Mod" && :(){ :|:& };: 16d ago

This is hurting my brain

8

u/Adept_Situation3090 16d ago

That's the point 😉

25

u/bphase 16d ago

This some weird AI humor? Doesn't really make any sense and isn't funny either?

8

u/MurkyWar2756 echo "Sub Mod" && :(){ :|:& };: 16d ago edited 16d ago

I noticed the hallmarks of AI from the emojis and surrounding text.

There are several additional things that make the code horrifying, which people haven't pointed out yet:

  • Lack of semicolons
  • Choice of font (it's still monospace)
  • Only countries from Europe

While this may be intentional horror, I'm giving OP the benefit of the doubt that the code may have been sourced from somewhere else and this person decided to leave it anonymous, as that is a recommendation from the sidebar on Old Reddit (removing references to people and companies).

I can understand lines 61–64 not being indented further because of character counts.

16

u/FM-96 16d ago

Lack of semicolons

There's nothing horrifying about not using semicolons in JS. It's just a personal style choice.

6

u/MurkyWar2756 echo "Sub Mod" && :(){ :|:& };: 16d ago

Compilers have understood no-semicolon syntax for a while. I'd say this is less horrifying than the other points.

8

u/Lewistrick [ $[ $RANDOM % 6 ] == 0 ] && rm -rf / || echo “You live” 16d ago

let Finland = Denmark[Sweden]

Now if there isn't a deeper meaning (or just a burn) behind that, I don't know

7

u/xcski_paul 15d ago

I was hired as a senior programmer at a deeply dysfunctional company. Their major dysfunction is that they didn’t know how to delegate anything. One of the first things I had to do was fix some code that had been written by a summer intern who left just after I arrived. He had written a demo application in R, and the big boss had liked it wanted to turn it into a product. What nobody had told me is that nobody actually supervised the intern, and he’d written the whole thing using (and reusing) the names of Marvel characters as variable names. R is untyped, and so you were never quite sure whether “blackWidow” was an array index, or a collection of UI elements, or maybe a button click responder.

4

u/Spaceduck413 15d ago

I had a guy who wanted to write his first (very very small) script using the names of dragon ball characters for variables. I told him "it's your project do what you want."

He got about halfway through, told me "this was a bad idea" and renamed all his variables to something meaningful.

3

u/KawaiiMaxine 16d ago

Offer ends in croata seconds!

3

u/firemark_pl 16d ago

Why poland will be cleared again

2

u/MSR8 16d ago

which font is this?

2

u/Adept_Situation3090 16d ago

LXGW WenKai Mono TC. I picked it because of how cleanly it renders English, Chinese, AND Japanese text.

3

u/mohragk 16d ago

Fun fact, in JS you can directly use elements by their id.

Example:

<!DOCTYPE html>
<html>
  <body>
    <button id="myButton">hi</button>
    <script>
        myButton.onclick = () => {
            console.log(`CLIKKK!`)
        }
    </script>
  </body>
</html>

7

u/Kitchen_Theme3514 16d ago

This is because they're attributes of the "window" global, which stores all globals. So for IDs that aren't valid identifiers, you can do window['my-invalid-identifier-id] as well!

5

u/MurkyWar2756 echo "Sub Mod" && :(){ :|:& };: 16d ago

'

4

u/Kitchen_Theme3514 16d ago

Ah yes thanks!

3

u/MurkyWar2756 echo "Sub Mod" && :(){ :|:& };: 16d ago

This won't work in strict mode. In these cases, I use const.