xiqe / code-train

前端算法

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Find numbers which are divisible by given number

xiqe opened this issue · comments

Find numbers which are divisible by given number

Complete the function which takes two arguments and returns all numbers which are divisible by the given divisor. First argument is an array of numbers and the second is the divisor.

Example

divisibleBy([1, 2, 3, 4, 5, 6], 2) == [2, 4, 6]

reply

function divisibleBy(numbers, divisor) {
  return numbers.filter(n => n % divisor === 0)
}