알고리즘 56 - Find numbers which are divisible by given number

tamagoyakii·2021년 10월 18일
0

알고리즘

목록 보기
56/89

Q.

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]

A)

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

어제 선생님이 알려주신거 써먹었다 !!!!! 으하하

0개의 댓글