DEV Community

Cover image for #7DaysJS: Even or Odd

#7DaysJS: Even or Odd

Lautaro Lobo on November 30, 2019

Welcome to day 2 of 7 Days of JavaScript! Let’s begin our journey today. We need to write a function that takes an array and gives back two values...
Collapse
 
jenc profile image
Jen Chan

I used a filter for even and odd, then a reduce for both. Probably cost the browser more power eh?

Collapse
 
lautarolobo profile image
Lautaro Lobo

Probably. Usually, for loops are faster, but maybe with larger inputs reduce outworks a for loop...