Because although 0 is a typeof integer but when you return 0 . It will not been include in the array as it is a false value in javascript.
Basically javascript considered 0 as false.
But in the same code if you write this

if(typeof(a)=='number'){
return true;
}

It will include 0 too.

In the case of typeof a == "number" ,it statisfy the condition as it is a interger.

I guess the filter solution has a lower compexity (Big O)and this will require less resources when run on big datasets.

Loops will have Logarithmic Time Complexity: O(log n), Quadratic Time Complexity: O(n²), or worst case Exponential Time Complexity: O(2^n).

Quadratic is when you have a loop within a loop Every loop iterates through every instance of the dataset. This becomes a very slow program that requires many resources. So loops are not the best way to program when working with big datasets.

Exponential is probably when you have a recursive function. They look so clean but they are often not the most effecient.

That's your problem. Don't print the result, but

returnit.This comment is hidden because it contains spoiler information about the solution

No random tests

thank you :D

It's a reference to the same list, so it's not a copy. You should make sure it's a copy :P

This comment is hidden because it contains spoiler information about the solution

???

This comment is hidden because it contains spoiler information about the solution

Because although 0 is a typeof integer but when you return 0 . It will not been include in the array as it is a false value in javascript.

Basically javascript considered 0 as false.

But in the same code if you write this

if(typeof(a)=='number'){

return true;

}

It will include 0 too.

In the case of typeof a == "number" ,it statisfy the condition as it is a interger.

Hope it would be helpful to you.

`console.log`

and`return`

aren't the same.Firstly I am sorry for my spoiler mistake.

My function returning correct in every example but codewars didn't approve it.

Please mark your post as having spoiler content next time. What is your function returning?

This comment is hidden because it contains spoiler information about the solution

Hi Inventer000,

In Short: efficiency of the code.

I guess the filter solution has a lower compexity (Big O)and this will require less resources when run on big datasets.

Loops will have Logarithmic Time Complexity: O(log n), Quadratic Time Complexity: O(n²), or worst case Exponential Time Complexity: O(2^n).

Quadratic is when you have a loop within a loop Every loop iterates through every instance of the dataset. This becomes a very slow program that requires many resources. So loops are not the best way to program when working with big datasets.

Exponential is probably when you have a recursive function. They look so clean but they are often not the most effecient.

Hope this is helpful?

This comment is hidden because it contains spoiler information about the solution

## Loading more items...