[Lv.0] 369게임

01수정·2022년 11월 18일
0
post-thumbnail

<입문 100문제> Day 14 - 조건문, 반복문, 시뮬레이션, 문자열

문제


풀이

function solution(order) {
    return [...('' + order).split('')].reduce((count, num) => (+num === 3 || +num === 6 || +num === 9) ? count+=1 : count, 0)
}

해답

function solution(order) {
  return [...('' + order)].filter(num => num === '3' || num === '6' || num === '9').length;
}
profile
새싹 FE 개발자

0개의 댓글