Ad
  • Custom User Avatar

    The reference solution was wrong, it was then fixed.

  • Custom User Avatar

    The assert answer is not right! No way that -61 is in between -66 and -96! Please correct it.

  • Default User Avatar

    This will incorrectly return 0 if arr[0] happens to be 0:

    alternateSqSum([0, 5, 7, 9, 12]); // returns 0 instead of 125
    

    What you wanted to do was check that arr isn't empty, to avoid reduce throwing an error. You could use arr.length to determine that it's not empty. However, if you just seed reduce with an initial value, then it can process an array of length 0, so you won't need to check the array's length at all.