repl.it
@CarlyRaeJepsenS/

Shared Scripts

Nodejs

When I need help, I use this.

fork
loading
Files
  • index.js
index.js
1
2
3
4
5
6
7
8
9
10
11
12
const divisibleNumbers = [];

let number = [2, 4, 5];
const divideFunction = number => {
  if (number % 2 === 0) {
    divisibleNumbers.push(number);
  } else {
    return "nope";
  }
};
number.forEach(divideFunction);
console.log(divisibleNumbers);