Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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. image text in transcribed
 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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advances In Databases And Information Systems 23rd European Conference Adbis 2019 Bled Slovenia September 8 11 2019 Proceedings Lncs 11695

Authors: Tatjana Welzer ,Johann Eder ,Vili Podgorelec ,Aida Kamisalic Latific

1st Edition

3030287297, 978-3030287290

Students also viewed these Databases questions