|
|
|
|
|
by scotttrinh
3397 days ago
|
|
When reading this, my immediate instinct was to say: "Easy!" import { flattenDeep } from 'lodash';
const flat = flattenDeep([1,2[3], [4, [5,6]]);
Not sure why employers care about developers being able to write utility functions from scratch, when that is not (typically) the job developers are hired for.Having said that, I lament the issues that the OP brought up: poor naming, unfamiliarity with their language's data structures, etc. Those are issues that will come up. Especially naming. |
|
Because of the reasons you listed in your next paragraph:
> poor naming, unfamiliarity with their language's data structures, etc. Those are issues that will come up. Especially naming.
No one actually wants a candidate to write "flatten". They want the candidate to demonstrate that they can work through a small problem and write something sane and functional. Utility functions tend to be small and reasonable to put together in about an hour.
With that said, I think this is a mediocre question because no one would create this list of lists-or-ints in Java. If presented well, the problem might be decent. If presented poorly, a lot of junior candidates would likely fail even if they're good candidates.