Ad
  • Custom User Avatar

    A test for .reduce() with a non-numerical start value would be useful to filter out buggy solutions like mine.

    [0,255,136].reduce(fn,"#") is perfectly valid (and might convert an RGB value to a CSS RGB value, in this case "#00FF88" or "#0F8").

  • Custom User Avatar
    Test.assertSimilar(reduce([], (result, arg) => result + arg), []);
    

    Excuse me???
    A normal reduce() function should return the default starting value (which is 0) when the array is empty (and the starting value is not passed in). Why is an empty array to be expected to return from it?
    You sure it is clear to you what this function is designed for?