3 ms·
My quick litmus test is to have someone write simple "map" and "reduce" functions in JavaScript.
by jcromartie 15y ago
My quick litmus test is to have someone write simple "map" and "reduce" functions in JavaScript.
- talmand 15y agoThat's funny to me, it seems your simple examples do the same thing as the Pascall's triangle example. I work in Javascript on a mostly daily basis and had no idea what they were. After about five minutes of researching I see what they are and how they work. The reason being is my day-to-day doesn't involve a large number of arrays, therefore I've had little need for those two examples. If I wasn't allowed to research those beforehand or have them explained then I would fail. Unless you allowed me to research it to show I can grasp new concepts and use them as needed. Now I've seen them I'll keep them in mind if I ever have a need for them. Although, in my research it was stated that these were extensions to the ECMA-262 standard and may not work everywhere. Therefore you would have to write up your own Array.prototype.map and Array.prototype.reduce to make them work. Is that true? If so, wouldn't seem simple to me unless you use them on a daily basis.
- YmMot 15y ago> If I wasn't allowed to research those beforehand or have them explained then I would fail It's implicit in all of these that the concept is explained to you. Nobody would ask you to "implement a X" expecting you to know what X was (be it Pascals triangle, fizzbuzz, map, etc) unless X happened to be a fundamental concept in the field you are working in (not the case for any of the examples so far) > Therefore you would have to write up your own Array.prototype.map and Array.prototype.reduce to make them work. Is that true? Yes, that's sort of the point here. Javascript has these functions as methods of arrays (in some implementations), but the idea of the test is to write your own. They're both pretty simple, basically a for-loop and some logic. On another note I have a hard time believing you work in JavaScript on a day to day basis and are not working with arrays. If you use jQuery or a similar library, you are working with arrays all the time and also using map-like functionality even if you don't know it by that name. $(".foo").click(function(){}) Takes an array of elements and maps over them.
- talmand 15y agoWell, that's true. I use jQuery and similar libraries as I primarily work on front end development for websites. I was speaking more of working with raw javascript and digging into the array without a library. But if you asked me to do what map() and reduce() ultimately do, which you say would happen more or less, then I'm fairly certain I could complete the task. It was more that I was saying I was unfamiliar with those two particular terms.