#7DaysJS: Even or Odd
Lautaro Lobo

Lautaro Lobo @lautarolobo

About: While you read this I'm learning something new.

Location:
Córdoba, Argentina
Joined:
May 6, 2019

#7DaysJS: Even or Odd

Publish Date: Nov 30 '19
5 2

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: one with the sum of all the odd numbers of the array, and other with the sum of all the even numbers on the array.

It can’t be that hard right?

You can read the solution to today’s challenge here.

Comments 2 total

  • Jen Chan
    Jen ChanNov 30, 2019

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

    • Lautaro Lobo
      Lautaro LoboNov 30, 2019

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

Add comment