サンタの工場はおもちゃの生産リストを受け取り始めました。
各行には、どのおもちゃを作るかと、何個作るかが書かれています。
いつものようにエルフたちは失敗してしまい、一部のおもちゃには意味のない数量が記入されています。
次の形をしたオブジェクトのリストが与えられます:
toy: おもちゃの名前(string)quantity: 作るべき個数(number)あなたのタスクは、このリストを受け取り、次の条件を満たす文字列の配列を返す関数を書くことです:
quantity で指定された回数だけ繰り返すconst production1 = [
{ toy: 'car', quantity: 3 },
{ toy: 'doll', quantity: 1 },
{ toy: 'ball', quantity: 2 }
]
const result1 = manufactureGifts(production1)
console.log(result1)
// ['car', 'car', 'car', 'doll', 'ball', 'ball']
const production2 = [
{ toy: 'train', quantity: 0 }, // no se fabrica
{ toy: 'bear', quantity: -2 }, // tampoco
{ toy: 'puzzle', quantity: 1 }
]
const result2 = manufactureGifts(production2)
console.log(result2)
// ['puzzle']
const production3 = []
const result3 = manufactureGifts(production3)
console.log(result3)
// []

