Question: I am creating an accumulator function for a practice problem that is supposed to filter odd elements in a numbers array. My code is passing

I am creating an accumulator function for a practice problem that is supposed to filter odd elements in a numbers array. My code is passing every test except for one (i have copied the tests below the picture). I cannot figure out why the second test is not passing, please look at my code and help me understand what I am doing wrong. Thank you.  I am creating an accumulator function for a practice problem that
 it should return an array  it should return an array with the odd elements from the passed in array Error: expected [ 1 ] to deeply equal [ 1, 3, 5 ]  it should return an array if there are no odd numbers  it should return an array if given an empty array

JAVASCRIPT Function filteroddElements (numbers) \{ if(numbers. length ===0)\{ return []; if(numbers [i]%2==0){ return [];} var oddNumbers =[]; for (var i=0; i

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!