I’m on a codewars challenge, and I get the correct output but it won’t return as an array for some reason. The problem is to take an input array and add all positive numbers and all negative numbers and return an array as [sum of positive numbers, sum of negative numbers] but my ouput always comes out right but not in an array.

```
function countPositivesSumNegatives(input) {
var output = [0,0];
for (i = 0; i < input.length; i++)
{
if (input[i] < 0)
{
output[0] = output[0] + input[i];
}
else if (input[i] > 0)
{
output[1] = output[1] + input[i];
}
}
return output;
}
```

It looks like an array to me when I run you code. In what way does it not look like an array to you?

1 Like

That may not be my problem then, for some reason I’m not getting the right output and I’m completely lost.

I’m starting to think that the input isn’t automatically in an array, so I tried turning it into a long string and then turning it into an array but still not working

Add `console.log(output)`

right before the return and see what is being returned by the function. And then read the instructions very closely again.

The function name makes me think you perhaps want to *count* the number of positive numbers?

Thank you, figured it out, the problem was kind of dumb and I didn’t read it carefully enough. It wanted the number of positive numbers and the sum of negative numbers, not the sum of both. Sorry to bother everyone with a trivial reading error, (facepalm), thank you for the help.

1 Like