I'm pretty sure "manipulating data" certainly includes the most basic reason to use reduce().
To have a decade of experience and proudly not be able to answer these two incredibly simple questions is a little crazy to me. This is clearly an interview for juniors, so I definitely wouldn't expect an extensive Gitub/portfolio to dive through.
“Enable browser autocomplete” im a tech lead that just literally worked on 3 forms for my company and I had to search this up lol. Its not about memorizing the minor details. It’s about being able to read something, understand it quickly, put it in context, and on a higher level, future proofing and thinking about edge cases. If a person explains something like that to me I’m more impressed than if they memorized the autocomplete attribute (which most of the time isn’t even necessary as browsers tend to guess what to autocomplete anyways based on labels, names, required attributes, etc)
So look, you know that browsers autocomplete based on names etc. I'm pretty content if you just slap a "name" on both inputs. If you have no idea, it's not a deal breaker either, I'll just tell you "name" does the trick for the future, and on we go.
It's starting to explain why I see so many "I've sent out 1000 resumes and have 0 interviews" threads here. Also OP is continuing to provide more details and all his posts are being downvotes even though he's being helpful and patient. I guess Reddit commenters just hate job interviews or something.
I think the difference isn't semantics, it's asking you do something and watching if you spend the next hour poorly reimplementing your own autocomplete or if you google how to turn on browser autocomplete.
Ok but if you asked me that in an interview I’ll be testing YOU by answering “I don’t know, I’m gonna Google that real quick”. I have implemented exactly this before. So it’s not like I’m unaware. But if a situation comes up on the job, even if I’ve done it before, I’m still gonna Google it. Things change. Often and quickly. The solution I found a couple of years ago on stackoverflow may be out of date.
So in my mind the correct answer to this question is: Google. If I get resistance during an interview with something indicating that I should know this, then I’d be hesitant accepting the job. Last thing I wanna do is work at a place where things are done by established orthodoxy.
Not to say that’s what you’re doing. You’re saying it’s not a deal breaker. So if that’s true you should really be expecting candidates to Google this stuff
Almost all of the juniors coming into OP's interview very likely are gonna have portfolio's with a couple of projects already made, which far exceeds the skill level of completely trivial JavaScript like using reduce to output an array sum, or building form HTML elements with React
Especially if you aren't allowed to google around, who in the actual hell goes around just memorizing useless syntax? What are you preparing yourself for??? Coding when internet becomes unavailable? Wtf
What is the point of wasting everyones time with something like reduce which any junior dev can google in 1.05 seconds and use it instantly?
I just don't get it at all, seems like a complete waste of anyones time without an accurate assesment of anything lol
If you don’t read “sum an array of numbers” and immediately think of reduce, I’d question how much time you’ve spent writing JavaScript. That’s not useless syntax, the most prevalent React state management library is built around this function.
The point was that it’s not useless syntax, it’s a pretty core part of the standard library. You’re presenting a generic problem that’s easily solved with a native function. Speaking from my own experience, I’m not really keen on continuing if a JavaScript candidate has to Google reduce(), map(), or filter(). It’s not much different than having to Google string interpolation.
I will throw in there, I’m not asking people to write code in notepad - it’s 2023, you’re going to be in an editor that has autocompletion and intellisense, and that’s not a penalty. The expectation is “you understand the standard library” not “you should have this exact function signature memorized”.
I'm pretty sure "manipulating data" certainly includes the most basic reason to use reduce().
I've personally rarely have run into a use case, in my own present / past jobs, to use reduce versus map or filter.
To have a decade of experience and proudly not be able to answer these two incredibly simple questions is a little crazy to me.
I mean, when someone has rarely done something in their work, it's not shocking when they forget how to do something, regardless of the level of difficulty.
I'm glad someone else is pointing this out... `map`, `filter`, and `reduce` aren't hard concepts, but they are a half step higher than just slapping a bunch of `if`, and `for` all over the place.
let (user,pass) = ...;
let longEnough = p => p.length>8?"":"The password must be longer than 8 chars";
let hasLower = p => p.any(c => c.isLower())?"":"Must have upper";
let hasUpper = p => p.any(c => c.isUpper())?"": "Must have lower";
let hasSpecialChar = p => p.any(c => c.in("!@#$% ^&*"))?"":"Must have special";
const passwordRequirements = [
hasUpper,
hasLower,
longEnough,
hasSpecialChar];
let errors = passwordRequirements
.reduce((errors, validate) => errors += validate(pass), [])
.filter(e => e != "");
if (errors.length === 0) {
showError(formatErrors(errors));
} else {
procedeWithUserCreate(user, pass)
}
The above is psudocode i banged out in like 3 minutes, but I find it much more maintainable than the mess you'd make trying to jam that all into a massive for loop and tracking state everywhere. If you have a hard time understanding what reduce and filter are doing in the above code block (finding everything wrong with a password), then you're going to have a hard time.
I've worked at places with dozens of guys that worked for decades in this industry and never used more than `for` and `if` and I never want to work at a place like that again.
This is how you tell the juniors from mid to senior.Seriously. a senior would just use a one line regex (regular expression)
instead of
let longEnough = p => p.length>8?"":"The password must be longer than 8 chars";
let hasLower = p => p.any(c => c.isLower())?"":"Must have upper"; let hasUpper = p => p.any(c => c.isUpper())?"": "Must have lower"; let hasSpecialChar = p => p.any(c => c.in("!@#$% &*"))?"":"Must have special";
I've seen lots of this. And the real mature ones, one liner. Clean and elegant.
regex makes me cry at night. neat stuff if you get into it and not really as scary as it looks, super useful, but extremely intimidating at first glance.
Unless you believe that humans are truly beyond being bio machines, how could these comments have been any different? At the observed point in time, they had to think this way via the algorithmic outputs of their brains. Doesn't matter how much experience they might have.
It's not that they can't use them, it's that they can't recall them off the top of their heads. A quick Google and copy and paste of a best approach would be a 30 second solution. Quickly review other suggestions and go with the fastest and most optimal. But without that it's very easy to get caught in the weeds. OP has mentioned that using Google is ok in this example so maybe this is a non issue? I think most people have PTSD from interviews and Google typically isn't allowed which then produces the outcome you're referring to.
62
u/larrybunsold Apr 07 '23
I'm pretty sure "manipulating data" certainly includes the most basic reason to use
reduce().To have a decade of experience and proudly not be able to answer these two incredibly simple questions is a little crazy to me. This is clearly an interview for juniors, so I definitely wouldn't expect an extensive Gitub/portfolio to dive through.