๐Ÿ’Ž

ARR PS - chess set

notion image
ย 
notion image
ย 

ํ’€์–ด๋ณด๊ธฐ

111228์ธ๋ฐ 012227์ด ๋“ค์–ด์™”๋‹ค๋ฉด
for๋ฌธ์„ ๋Œ๋ฉด์„œ ๊ฐ™์€ ์ธ๋ฑ์Šค์˜ ๊ฐ’์„ ๋นผ์„œ result์— ๋„ฃ์–ด์ค€๋‹ค.
ย 
function answer(chess) {
    let result = [];
    const needs = [1, 1, 1, 2, 2, 8];
    chess.forEach((v, i) => result.push(needs[i] - v));
    console.log(result);

    return result;
}