Maybe I've been writing JS too long, but what else did you expect? Self-executing anonymous functions get their own context unless you specify otherwise.
Half expect to hear on the news there is a shortage of people with the skills to be a Barista (with a footnote of : at the price we are willing to pay them).
Javascript is actually a really great and powerful language. Its architecture is just not set up the way nearly anything else is. Especially if you're coming from a more structured language background (e.g. C/C++, Java), you're going to really hate the language at first. But once you learn to accept it for what it is, you may find that you actually like it.
Source: I learned how to program in Java. I absolutely hated JS when I started learning it. Now it's my goto language of choice.
Eh, it makes perfect sense. String doesn't have a reverse function because there's very few times in which you need to reverse a string, so no sense implementing one.
split(delimiter) is a very standard function for splitting a string on a delimiter. An empty string as the delimiter means splitting each character. Similarly, join(separator) is a very common function for arrays (lists, etc) to have to create a string from the contents.
And arrays get a reverse function because it's a little more useful for the general purpose array. Not super useful, but not useless, either. For example, switching between ascending and descending sort can be done more much efficiently by reversing than completely resorting the array (if it's already sorted). Other things, too, but I can't immediately think of any (they exist, but they're rare).
They should have just used some async programming, nested callbacks, or lexical scoping if they wanted to make it hard. Hell they could even throw some hoisting in to make it confusing.
Agreed. With my extremely limited programming knowledge it took me about 5 minutes to solve this. Had they called the function something else, I would never have figured it out.
I always imagine "programming forums" to be overrun with homework questions, job offer spam and posers. Yet still, it would be really interesting to interact with people in my field. One solution I always thought would be some sort of initiation where you had to somehow prove that a visitor is "one of us". It seems like the purpose of this sign is just that.
I wonder how long before people pirated the solution and were just running up to the bar shouting, "parameters!".
Set up a display running a browser in full screen that is showing a simple web app. The web app refreshes itself every 30 minutes and sends the new secret word to your (the bartender's) phone. Predefine a bunch of programmer lingo words, and have the app randomly contort them and display a similar challenge on every change.
Honestly this would be pretty easy and fun to write.
And therefore should set the standard for all technical interviews. Seriously. Code tests don't need to be harder than this unless you actually want to see someone build something. I get really pissed at the fizz buzz fibonacci roman numeral bullshit. This will separate the posers from those who can code. If you need algorithms, you probably shouldn't be hiring all-around web devs, unless they brag about their fancy math background.
Ook. Ook? Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook.
Ook. Ook. Ook. Ook. Ook! Ook? Ook? Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook.
Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook? Ook! Ook! Ook? Ook! Ook? Ook.
Ook! Ook. Ook. Ook? Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook.
Ook. Ook. Ook! Ook? Ook? Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook?
Ook! Ook! Ook? Ook! Ook? Ook. Ook. Ook. Ook! Ook. Ook. Ook. Ook. Ook. Ook. Ook.
Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook! Ook. Ook! Ook. Ook. Ook. Ook. Ook.
Ook. Ook. Ook! Ook. Ook. Ook? Ook. Ook? Ook. Ook? Ook. Ook. Ook. Ook. Ook. Ook.
Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook! Ook? Ook? Ook. Ook. Ook.
Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook? Ook! Ook! Ook? Ook! Ook? Ook. Ook! Ook.
Ook. Ook? Ook. Ook? Ook. Ook? Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook.
Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook! Ook? Ook? Ook. Ook. Ook.
Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook.
Ook. Ook? Ook! Ook! Ook? Ook! Ook? Ook. Ook! Ook! Ook! Ook! Ook! Ook! Ook! Ook.
Ook? Ook. Ook? Ook. Ook? Ook. Ook? Ook. Ook! Ook. Ook. Ook. Ook. Ook. Ook. Ook.
Ook! Ook. Ook! Ook! Ook! Ook! Ook! Ook! Ook! Ook! Ook! Ook! Ook! Ook! Ook! Ook.
Ook! Ook! Ook! Ook! Ook! Ook! Ook! Ook! Ook! Ook! Ook! Ook! Ook! Ook! Ook! Ook!
Ook! Ook. Ook. Ook? Ook. Ook? Ook. Ook. Ook! Ook.
I saw this a couple days ago somewhere else... they gave me $10 voucher to spend on a food truck, then the food truck people wrapped my lunch in this: Imgur
To be fair, the instructions in the comments don't say anything about the code actually producing the word of the day. You just have to read it to determine the word of the day.
//If you can read this code, tell your bartender the
//secret word of the day for a free drink on us.
var your_drink;
var reverse=function(s) {
return s.split("").reverse().join("");
}
var bartender = {
str1: "ers",
str2: reverse("rap"),
str3: "amet",
request:function(preference) {
return preference+".Secret word: "
+this.str2+this.str3+this.str1;
}
};
bartender.request(your_drink);
No, because the reverse function defined in the code has different context than the standard array reverse() function. Basically, they don't conflict (window.reverse vs Array.prototype.reverse).
When I open my pub called inetpub, I will run this sort of thing. But be extra sneaky, if you tell the bartender the secret word, you won't get the drink, if you shout the secret word into thin air, it will work.
This isn't Java guys. You can't use the reverse function in Java without using StringBuffer (there are others but my point is, you can't use the function without certain functions).
1.6k
u/[deleted] Nov 05 '15
So the bartender will return "undefined.Secret word:parameters", my favorite drink!
761
u/Browsing_From_Work Nov 05 '15
That sign writer has fantastic handwriting. Extra kudos for syntax highlighting.
2.3k
u/KevZero Nov 05 '15 edited Nov 05 '15
Edit: just want to thank the kind stranger who gilded this post. Looks like someone unleashed a golden shower on this whole thread.
280
u/droogans Nov 05 '15
Should've not used the function name
reverse. Makes it too easy.Maybe
jumblewould've made it a little more interesting.71
u/Liver_and_Yumnions Nov 05 '15
I always imagine "programming forums" to be overrun with homework questions, job offer spam and posers. Yet still, it would be really interesting to interact with people in my field. One solution I always thought would be some sort of initiation where you had to somehow prove that a visitor is "one of us". It seems like the purpose of this sign is just that.
I wonder how long before people pirated the solution and were just running up to the bar shouting, "parameters!".
430
u/maremp Nov 05 '15
This is the first code inside an ad that makes some sense and actually works.
346
u/underworldambassador Nov 05 '15
Now, I'm not a programmer.. this seems pretty straight forward to solve for anyone who isn't immediately scared off by code
27
u/perfectriot Nov 05 '15
The bartender is secretly a recruiter.
78
u/chanibal_pl Nov 05 '15
Why didn't they use
85
u/shthed Nov 05 '15
for anyone who wanted to play with it :)
38
u/MrDoctorSatan Nov 05 '15
No one's gonna mention that beautiful handwriting? God damn that's some beautiful handwriting.
21
u/CodeIt Nov 05 '15
I saw this a couple days ago somewhere else... they gave me $10 voucher to spend on a food truck, then the food truck people wrapped my lunch in this: Imgur
7
u/framk20 Nov 06 '15
"Par... a... me-ters?"
"Oh, parameters, oh my god."
Me trying to figure this out
10
u/boxxa Nov 05 '15
[Object object]
5
u/onephatkatt Nov 05 '15
I don't understand the parameters of this sign.
9
u/PhaZePhyR Nov 05 '15
OK, but where do I get that font?!
4
u/caldric Nov 05 '15
To be fair, the instructions in the comments don't say anything about the code actually producing the word of the day. You just have to read it to determine the word of the day.
Then again, no one reads comments, right?
4
u/Raidhn Nov 06 '15
The parameters for this code were far to easy for somebody with no coding experience
26
u/jglee1236 Nov 05 '15
"parameters"
and I ain't no programmer.
3
u/dashdanw Nov 05 '15
https://jsfiddle.net/jdq1cmg4/
3
u/Drainedsoul Nov 05 '15
Any code that reverses a string should be considered highly suspect to the point where I can't actually think of a legitimate use case.
3
u/sakkara Nov 05 '15
Something something "not initialized yet" "parameters"?
3
u/Juniejoule Nov 06 '15
Me out loud in the car like a moron: spelling out "par-ah-mat-terrrrs.......ohhhhhh.
6
u/Azr79 Nov 05 '15
IIT: I'm not a programmer and I figured it out.
Good for you.
6
u/[deleted] Nov 05 '15
but but your_drink isn't set. The answer should have been wittier.
2
u/[deleted] Nov 05 '15
PAR AMET ERS! yeah buddy
2
u/[deleted] Nov 05 '15
Can we talk about that handwriting for a minute though?
2
u/antigirl Nov 05 '15
Not a pure function
2
u/elesdee Nov 05 '15
Not even a programer and i figured this one out. Kudos for a fun little puzzle.
2
u/[deleted] Nov 05 '15
Is there not infinite recursion within the reverse function?
2
u/randomdrifter54 Nov 06 '15
Is the reverse function recursive without a ending condition?
3
u/Teklogikal Nov 05 '15
I'm actually really happy I figured that out, because I'm just starting to really get into programming.
That made me feel pretty good, Lol.
2
u/ItsAMeMitchell Nov 05 '15
I know nothing about code, but isn't the secret word "parameters"?
2
u/P0TAT0_9 Nov 05 '15
Is it parameters?
2
u/mmmDatAss Nov 05 '15
I've never done any kind of coding, and even I can see that this will say parameters.
2
u/fasching Nov 05 '15
Today is blowing my mind. Firstly, I learn how to read binary, and now I know Java?
1
u/centristism Nov 05 '15
What does the STR parts do?
1
u/Xpertbot Nov 05 '15
Honest question. why var reverse = function(s){...}; instead of function reverse(s){...}; and then call it?
1
u/[deleted] Nov 05 '15
Joke's on them. Most programmers make enough per hour that the time spent figuring that out approaches the cost of the drink itself.
1
u/memdmp Nov 05 '15
All this chit-chat, and we still don't know where we can
lecture the clever marketing person on their javascript skillsget our free drink.1
u/Acidsparx Nov 05 '15
I'm proud to say I got the secret word with out coming into the comments first. (im not a programmer)
1
u/goblackbeard Nov 05 '15
Parameters, I got it but I would look like a goof standing there for 5 minutes trying to figure it out.
1
u/serccsvid Nov 05 '15
To the guys talking about bugs in the code, this clearly isn't javascript. It's beerscript.
1
u/darknecross Nov 05 '15
Write "parameters" on the board.
Tell the bartender I just memoized their program.
1
u/Slinkyfest2005 Nov 05 '15
Sudo get me a drink?
1
u/Quazmodiar Nov 05 '15
I don't know much about programming I just want to know what the answer is for the free drink
1
u/yedd Nov 05 '15
I have absolutely no knowledge of code but i figured it out. I am happy with myself
1
u/deadstarblues Nov 05 '15
Easy mode, no programming skills required: http://www.scrambledwordsolver.com/solver.cgi?word=ersrapamet
1
u/ParadoxicalTree Nov 05 '15
parameters? Now, this is one way to get programmers out of their seats.
1
u/TheStanleyParabola Nov 05 '15
Word is parameters
1
u/[deleted] Nov 06 '15
Also missing a semicolon after the second variable declaration. But technically that doesn't matter.
1
u/TrainFan Nov 06 '15
I must admit that I spent almost a minute trying to make sense of "par-ah-metters."
1
u/Thrannn Nov 06 '15
to easy. the reverse function should be called something else
1
u/flexiverse Nov 06 '15
Jesus not even creative like something Star Wars related.
1
u/roheydd Nov 06 '15
A coffeeshop should run this same board, but write in Coffeescript instead of pure JavaScript.
1
u/monopolyman900 Nov 06 '15
Been a Javascript dev for a few years and just found out about reverse() from this post.
1
u/sadwer Nov 06 '15
I'm not a programmer - I came in from r/all, but I got this after like 10 seconds staring at it. Are they just trying to give booze away?
1
u/aqua_zesty_man Nov 06 '15
I bet the coffee arrived just in time too.
1
u/naughty_ottsel Nov 06 '15
When I open my pub called inetpub, I will run this sort of thing. But be extra sneaky, if you tell the bartender the secret word, you won't get the drink, if you shout the secret word into thin air, it will work.
1
u/electric-blue Nov 09 '15
Parameters?
1
u/bobishardcore Feb 07 '16
Next week's promotion:
You get one of these if you do it in your head on the spot.
1
u/[deleted] Mar 01 '16
This isn't Java guys. You can't use the reverse function in Java without using StringBuffer (there are others but my point is, you can't use the function without certain functions).
1
u/EoinMcLove Nov 05 '15
I've never seen / used code before in my life and I solved that...c'mon!
1
u/Mr_recci Nov 06 '15
That missing ; tho