re: 28 Relevant Javascript Interview Questions Part I - The first 4 VIEW POST

VIEW FULL DISCUSSION
 

Thanks for writing this up. Obviously interviewing is broken, but I still take issue that a "correct" solution would rely on the knowledge of the existence of a specific function, i.e. sum in example two. I would hope that reduce or another efficient option would be just as acceptable. If not, it ends up being more about wrote memorization/keyword knowledge than about being able to breakdown the problem. Which is, theoretically, the point of the arduous technical interviews we have at present.

 

Hello Laurie thank you for reading and taking the time to add to the discussion. I think after reading your comment that maybe the wording of the challenge is not clear. The intent is to actually have the candidate write a sum function since it does not exist on the Array prototype methods like map, filter or reduce. In doing so the candidate should be careful in not overriding a possible future implementation of it - say for example if the method was to get added natively in ES8 or later.

For example if I was asked to add a method to the Array prototype that doubles each number in an array, a simple first step might be:

Array.prototype.doubles = function() {
 return this.map(n => n * 2);
}

And [2,4,6].doubles() will return [4,8,12].

Of course, that is the first step and there is more to it to make it more future proof - but hopefully that clarifies the intent.

Let me know if the wording needs to be revised.

Thanks again :)

 

Ah, I was gonna say, I didn't know that WAS a function on array!

I think this is the line that is a bit confusing You have been keeping up to date with new stuff in JS but are not sure that sum() is part of the Array prototype methods. That implies that it might be and you just don't know it? I might say, You have been keeping up to date with new stuff in JS and know that sum() is not part of the Array prototype methods.

I think you are right and that section might need a bit of a revision to be clearer. I will take a stab at it, feel free to propose something as well.

code of conduct - report abuse