[Lv.1] x만큼 간격이 있는 n개의 숫자

01수정·2023년 11월 2일
0

문제


풀이

function solution(x, n) {
    let answer= [x]
    for (let i=1; i<n; i++) {
        answer.push(x+x*i)
    }
    return answer
}

다른 풀이

function solution(x, n) {
    return Array(n).fill(x).map((v, i) => (i + 1) * v)
}
profile
새싹 FE 개발자

0개의 댓글