Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
With all due respect, you are not right. Function squareSum() takes one argument, not two. Let me explain: func squareSum([],[1,2,2]) will only look for a first argument, which is [] (empty array), and thus result is 0. Also, if you would to call func squareSum([1,2,2], []), the result would be, as expected, 9.
The
squareSum
function takes in one single argument, an array of numbers. Your example callssquareSum
with two arguments, which is not part of the spec. Not a kata issue.squareSum([], [1,2,2]) returns 0 which is fundamentally WRONG!
It should be 9! even after you initialize the default value of reduce to 0 or []
The issue lies within Javascript limitations.
add 0 or [] to reduce, (sum, 0) for example. this Excercise is fundamentally wrong because it returns purposefully zero when given and empty array so, don't be upset about this challenge.
None of these functions solve the problem; for example
squareSum([],[1,2,2]) returns zero, which is WRONG!
it should return 9 and not 0!!!!