---
# System prepended metadata

title: "\U0001F3C5 5/4 (二) 每日任務 Day 7"
tags: [Vue 直播班 - 2021 夏季班]

---

# 🏅 5/4 (二) 每日任務 Day 7
###### tags: `Vue 直播班 - 2021 夏季班`

題目 (使用 CodePen 作答)
---
小明有固定存錢的好習慣，以下是小明的銀行帳戶資訊。
1. 請協助他將存款資訊 mingTransfer 的內容合併到 mingAccount.depositRecord 陣列中 (使用 `.push()`)。
2. 請將他各月的存款累加到 mingAccount.deposit 中 (可以使用 `forEach()` 或 `reduce()`)

參考: https://developer.mozilla.org/zh-TW/docs/Web/JavaScript/Reference/Global_Objects/Array/Reduce

```js=
// 小明的銀行帳戶資訊
let mingAccount = {
  name: '小明',
  age: 22,
  deposit: 10000,
  depositRecord: [
    {
      title: '開戶',
      amounts: 10000
    }
  ]
};
// 小明的存款資訊
let mingTransfer = [
  {
    title: '一月存款',
    amounts: 777
  },
  {
    title: '二月存款',
    amounts: 7000
  },
  {
    title: '三月存款',
    amounts: 70000
  }
]
console.log(mingAccount);
```

回報流程
---
請同學依照下圖教學觀看解答、回報答案:

![](https://i.imgur.com/QtL8zEW.png)

回報格式如下圖，請在「回報區」使用註解回報答案 (為了統計人數，請同學依序加上「報數」)

![](https://i.imgur.com/L7kyew8.png)

<!-- 解法一
mingTransfer.forEach(item => {
	mingAccount.depositRecord.push(item);
    mingAccount.deposit += item.amounts;
})
console.log(mingAccount);
-->

<!-- 解法二
mingTransfer.forEach(item => {
	mingAccount.depositRecord.push(item);
})
mingAccount.deposit = mingAccount.depositRecord.reduce((prev, curr) => {return prev + curr.amounts}, 0);
console.log(mingAccount);
-->

回報區
---
<!-- 1:Alpha
codepen:https://codepen.io/alphatero/pen/NWdQQEQ
-->

<!-- 2:Jasmin
codepen:https://codepen.io/thejasmin/pen/dyOVxoL?editors=0111
-->

<!-- 3:Lina Chen
codepen:https://codepen.io/LinaChen/pen/qBReeLp
-->

<!-- 4:Izumi 泉
CodePen: https://codepen.io/izumi-dev/pen/gOgEZzM
-->

<!-- 5:Amanda Chiang
CodePen: https://codepen.io/cym199922/pen/GRrVVaz?editors=0011
-->

<!-- 6:kevin嘉軒
CodePen: https://codepen.io/kevin-chang-the-sasster/pen/PopYYYv
-->

<!-- 7:chou allen
CodePen:  https://codepen.io/eepson123tw/pen/yLgmmdJ?editors=1111
-->

<!-- 8:Yi Chieh
CodePen:https://codepen.io/Yi-Chieh/pen/eYvOOmW?editors=1111
-->

<!-- 9:Jrhung-Tsai
CodePen:https://codepen.io/Araytsai/pen/JjWPPjp?editors=0011
-->
<!-- 10:Olga
COdePen:https://codepen.io/heavenbird_0221/pen/rNyBBaw?editors=1112
-->

<!--11:yijun
CodePen:https://codepen.io/sandy3068/pen/PopYYmo
-->

<!-- 12. Harold
CodePen:https://codepen.io/YuWin0805/pen/wvJwwKv
-->

<!-- 13. Vic
CodePen:https://codepen.io/hsuan333/pen/oNBKKaE
-->
<!-- 14. 小魚
CodePen:https://codepen.io/jarvis1993/pen/mdWbbqN?editors=0011
-->

<!-- 15: Alvin Chu
codepen:https://codepen.io/wave99487chu/pen/KKWPPKz
-->
<!-- 16: Li Shang
codepen:https://codepen.io/li-shang/pen/yLgmmwO
-->

<!-- 報數 17 : SeanLiu
codepen:https://codepen.io/LuckyTiger/pen/yLMBBKo -->

<!-- 報數18： youting
codepen: https://codepen.io/youtingluo/pen/MWpggEv
-->

<!-- 報數19： shoppingq
codepen: https://codepen.io/shoppingq/pen/qBrWBEz
-->

<!-- 報數20: Erica
Codepen:
https://codepen.io/ericadu/pen/yLMBLBK
-->
<!-- 報數21: 陳sam
Codepen:https://codepen.io/euldpliv/pen/qBrWWNK?editors=0111
-->

<!-- 報數22: Sec
Codepen: https://codepen.io/Sentiments/pen/yLMBBRP
-->

<!-- 報數23: Ethan
codepen: https://codepen.io/blazer030/pen/bGqbGWY
-->

<!-- 報數24: Alysa Chan 
codepen: https://codepen.io/alysachan/pen/BaWBaVJ?editors=0011
-->

<!-- 報數25: Larry 
codepen: https://codepen.io/manpower0708/pen/abJozyB?editors=1012
-->

<!-- 報數26: Joe Kuo 
codepen: https://codepen.io/alertislow/pen/ExWYaWy?editors=0012
-->

<!-- 報數27: Ray 
codepen: https://codepen.io/posidomcode/pen/OJpLPza
-->

<!-- 報數28: Carrie
codepen: https://codepen.io/echocarriet/pen/BaWByMe
-->

<!-- 報數29: 圈圈
codepen: https://codepen.io/wei-the-lessful/pen/gOmYbpe
-->

<!-- 報數30: Dah
codepen: https://codepen.io/hua0124/pen/yLMBNBJ
-->

<!-- 報數31: Iven
每日任務回饋 (選填):
沒想到要先用forEach把值取出來在push到原本的陣列裡面。
codepen: https://codepen.io/rtorihnk/pen/xxqKGKp?editors=0012
-->

<!-- 報數 32 : SONYKO
ㄏㄡˊ ～～ 前面的沒報數 ((((
codePen: https://codepen.io/s_syoujyo/pen/xxqKGdz
-->

<!-- 報數 33：家齊
Codepen: https://codepen.io/jacky298/pen/ExWYjbL
-->

<!-- 報數 34：Chiang
Codepen: https://codepen.io/ChiangJ/pen/bGqbdpN?editors=0011
-->

<!-- 報數35: leolee
每日任務回饋 (選填):
小明3月的存款高達7萬是中樂透了嗎?
codepen: https://codepen.io/nekorice/pen/yLMByMB
-->

<!-- 報數35: jimmyFang 
codepen: https://codepen.io/pohxiqqo/pen/ExWYPyK
-->

<!-- 報數36: YOYO
codepen:https://codepen.io/lumedkle/pen/jOBNWvO?editors=1111
-->


<!-- 報數37: Eric-小偉哥
codepen:https://codepen.io/ericLoveDesign/pen/zYZOqWj?editors=1111
-->

<!-- 報數38: Ted Kuo
codepen: https://codepen.io/TedKuo/pen/vYxBKJK
-->

<!-- 報數39: Stacey Huang
Codepen: https://codepen.io/staceyhuang/pen/ZEezWNx?editors=1011
-->

<!-- 報數40: Stacey Huang
Codepen:https://codepen.io/yxzzktmb/pen/xxqKEgE?editors=0011
-->
<!-- 同學不好意思，我們剛同時編輯了，要在麻煩你再改一下名字唷，我往下加 :) -->

<!-- 報數41: JessieCheng
每日任務回饋:
    想詢問關於 reduce 用法：array1.reduce((accumulator, currentValue, currentIndex, array2) => accumulator + currentValue, initialValue)
    function 裡面的參數 array2 就等於呼叫 reduce 的 array1，不知道什麼時機會使用到 array 呢？
Codepen: https://codepen.io/JessieMosbi/pen/abJoByG?editors=0011
-->

<!-- 報數42: Jordan Tseng
Codepen: https://codepen.io/jordan-ttc-design/pen/ZEezLyq?editors=0001
-->

<!-- 報數43: moitw
Codepen: 
https://codepen.io/tsuifei/pen/abJopLg?editors=0012
-->

<!-- 報數44: Sean cai
Codepen: https://codepen.io/SeanLibra/pen/LYWPxXG?editors=1111
-->

<!-- 報數45: Wendy Li
Codepen: https://codepen.io/rockayumitw/pen/wvJwgbj?editors=0011
-->

<!-- 報數46： RitaHuang
Codepen：
https://codepen.io/Rita-Rossweisse/pen/rNyBjoE?editors=0012
-->

<!-- 報數47： 涂阿銘
Codepen：
https://codepen.io/asd40441/pen/yLMBMdO?editors=0011
-->

<!-- 報數48： Echo Hui
Codepen: https://codepen.io/echohuiecho/pen/abJowvX?editors=0011-->

<!-- 報數49： tim Chou
Codepen: 
https://codepen.io/tim-chou/pen/eYvORKX?editors=0111
-->

<!-- 報數50： Echo
Codepen: 
https://codepen.io/bcq65958/pen/wvJwqPR?editors=1112
-->

<!-- 報數51: Alicia Lo
Codepen:
https://codepen.io/dkcyhyre/pen/rNyBGBj
-->

<!-- 報數52: Ed Huang
Codepen:
https://codepen.io/yide1986/pen/zYZOExz?editors=0012
-->

<!-- 報數53: 李重炫
Codepen:
https://codepen.io/otherway1123/pen/RwpbgRr?editors=1011
-->

<!-- 報數54: peter.chen1024
codepen:https://codepen.io/JIAN-RONG/pen/NWpKXWB
-->

<!-- 報數55:阿倫
CodePen:https://codepen.io/jason5125122/pen/wvJwmEP
-->

<!-- 報數56: Tori
CodePen:https://codepen.io/hayen/pen/poRYxEQ?editors=0012
-->

<!--
報數 57 : Valerie
codepen: https://codepen.io/vicky-chang/pen/abJoRBV?editors=1012
-->

<!--報數 58 : Wu Jung Han
codepen: https://codepen.io/JungHanWu/pen/MWpgLKe?editors=0012
-->


<!-- 報數59: Wei 
CodePen: https://codepen.io/uwhhiaxx/pen/yLMBwWG?editors=0012
-->

<!-- 報數60: Amber
CodePen:https://codepen.io/amberTing/pen/qBrBZrx?editors=1012
-->

<!-- 報數61: Josh Fang
mingTransfer.forEach(item => {
  mingAccount.depositRecord.push(item);
  mingAccount.deposit += item.amounts;
});
-->

<!--報數62: Fred Chang
CodePen: https://codepen.io/fred8196/pen/eYvYPMv?editors=1111
-->

<!--報數63: Yiren
CodePen: https://codepen.io/Yiren_Liou/pen/eYvmprK?editors=0012
-->

<!--報數64: Chiayu
CodePen: https://codepen.io/c85771029/pen/LYWEbZj
-->

<!--報數65: Channing
CodePen: https://codepen.io/Channing/pen/abJzJav
-->

<!--報數66: Tofu Tseng
每日任務回饋：
希望 reduce 的部分可以說明：
1. 為何 prev 不需要寫成 prev.amounts？
2. 中間 reduce 實際做了哪些事？
為何只要在 return prev + curr.amounts 就可以回傳所有的總和？console.log 也只能知道他做了加總的動作，但其實不太理解。

CodePen: https://codepen.io/Tofutseng/pen/QWpwJEE?editors=0012
-->

<!--報數67: twoz
CodePen: 
https://codepen.io/twoz/pen/eYvNmWb?editors=0012
-->


<!--報數 68: Jay
CodePen: 
https://codepen.io/jayredk/pen/xxqGGqR?editors=0012
-->

<!-- 報數 69: FuChang
CodePen: https://codepen.io/fuchang830714/pen/OJpJqPV
-->


<!-- 報數 70: Carol
CodePen: https://codepen.io/taonong/pen/WNpQpad
-->

<!-- 報數 71: MM
codePen: https://codepen.io/MINN3/pen/JjWGmjQ
-->

<!-- 報數 72:田
codePen: https://codepen.io/ccyy915/pen/JjWXoya
-->

<!-- 報數 74: Andrew Chi
codePen:https://codepen.io/wheresandrew/pen/gOmMVwQ
-->

<!--  報數75：kevinhes
codepen:
https://codepen.io/dwpwdpad/pen/dyvpKzr?editors=0011
-->

<!--  報數76：Emily Hsi
codepen:
https://codepen.io/EmilyHsi/pen/yLMVzea
-->

<!--  報數77：Butters
codepen:
https://codepen.io/Butterscode/pen/vYxmWNQ
-->

<!--  報數78：WA
codepen:
https://codepen.io/ldddl/pen/MWmgOBa?editors=0010
-->