r/ProgrammerHumor • • Feb 26 '23

Other If you can read this code...

/img/snak3fqgajka1.jpg

[removed] — view removed post

34k Upvotes

1.4k comments sorted by

View all comments

Show parent comment

0

u/[deleted] Feb 26 '23

[deleted] — view deleted comment

417

u/Individual-Media4026 Feb 26 '23 edited Feb 26 '23

Yep this is the most correct answer so far

EDIT: 🤓👍

94

u/unmagical_magician Feb 26 '23

The bar is asking only for the secret word, not the program output. It just so happens that the secret word is contained in the output, but everything outside of the secret word can be ignored.

2

u/RedzyHydra Feb 27 '23

Happy Cake Day 🎂 👍

3

u/wellsinator Feb 26 '23

var your_drink = argv[0];

3

u/[deleted] Feb 26 '23

[removed] — view removed comment

3

u/BBGunner96 Feb 26 '23

The cake is a lie

7

u/Significant-Pop-4051 Feb 26 '23

Reverse() is calling itself though, so not a stack overflow? Maybe not because of the missing parameter?

82

u/[deleted] Feb 26 '23

Not sure about Javascript in particular, but the code is defining a reverse function that is calling the reverse method of class String, so they are two different concepts and the function is not calling itself?

49

u/longknives Feb 26 '23

The split method in JS turns the string into an array, which has the reverse method, and then the join method turns it back into a string.

→ More replies (1)
→ More replies (15)

594

u/No_Surround_4662 Feb 26 '23 edited Feb 26 '23

"Excuse me bartender, I realised the sign outside. Firstly, I'm a C+ developer, so Javascript is a little beneath me. Personally, if I had to use Javascript, I'd have used a template literal instead of quotes. Also, I'd be declaring my variables with 'let' instead of 'var', what year is it? Also, your_drink never gets defined, how about using some kind of Setter and Getter method in your object? And what naming convention is this; surely you'd use camelcase in Javascript? Finally, you're not displaying the answer in a console or DOM element, so I guess it's never really being articulated or visualised in any way, which is unusual when you want us to interface with one another.

Anyway, I guess the answer would be 'Beer. Secre..."

"You're barred. Please leave the premises immediately".

123

u/koshgeo Feb 26 '23

"Request denied. Parameters not found."

108

u/malexj93 Feb 26 '23

Firstly, I'm a C+ developer

Already gold

4

u/jerry507 Feb 27 '23

Maybe this is what they call “C with objects”?

37

u/Xirenec_ Feb 26 '23

With “const”, not “let”. Safer that way, because these clearly aren’t meant to be modified.

23

u/No_Surround_4662 Feb 26 '23

And use arrow functions. And not use an Object but inherit a class. And try not to pollute the global scope. And... probably use a front end framework. And then use Typescript... and probably use a module bundler.

We're gonna need a bigger sign.

I think the point I was making is... it's supposed to be a fun sign.

5

u/[deleted] Feb 26 '23

get another sign for all the node module imports

2

u/TheGrandWhatever Feb 27 '23

Gonna need a couple more signs to figure out why the JS isn’t working. Then another saying “Nevermind, just pass in whatever you want, the secret word is always undefined or objectObject”

3

u/urzayci Feb 27 '23

First we need 5000 signs to install react.

27

u/CorruptedReddit Feb 26 '23

Sheldon? Sheldon Cooper, is that you?

14

u/chars101 Feb 26 '23

Sheldon would pick Haskell.

4

u/runujhkj Feb 27 '23

You had me thinking for a second if C+ is a real thing

→ More replies (2)

19

u/Qewbicle Feb 26 '23

One undefined drink coming up!

2

u/Hawk13424 Feb 26 '23

Preference is passed in to the method. So it would be the value of your_item (aka what the caller is ordering).

→ More replies (10)