---
# System prepended metadata

title: "\U0001F3C5 DAY35 每日任務"
tags: [JS 直播班  - 2021 秋季班]

---

# 🏅 DAY35 每日任務
###### tags: `JS 直播班  - 2021 秋季班`

今天來看看箭頭函式怎們寫！ Let's GO ！

很多人以為箭頭函式是傳統函式簡化的寫法，但他們兩個是完全不同的東西哩。傳統函式是 ES6 之前的所以名稱叫做傳統，而箭頭函式是 ES6 後出的。


## 箭頭函式寫法
```javascript=
/* 傳統函式 */
let cat = function(name){
	return ` 我的貓貓叫 ${name} `
}
console.log (cat('Miu'))
	// " 我的貓貓叫 Miu "


/* 箭頭函式 */
let arrowCat = (name) => {
	return ` 我的貓貓叫 ${name} `
}
console.log (arrowCat('Miu'))
	// " 我的貓貓叫 Miu "
```

宣告變數、並賦予它函式，我們稱這段 code 為「 函式表達式 」
上面範例都屬於 函式表達式。

　

其實我們還可以把那個箭頭函式再簡寫：
```javascript=
/* 箭頭函式簡寫 */
let arrowCat = (name) => ` 我的貓貓叫 ${name} `
console.log (cat('Miu'))
	// " 我的貓貓叫 Miu "
```

什麼！ 大括號直接拿掉了嗎 Σ(´□`;)

這個寫法是 函式表達式限定！
箭頭後面不加大括號的話、就是 return 的意思。

所以我們 console 得到的結果都是一樣滴。

上面那段code 還可以再簡寫喔 ！

```javascript=
/* 箭頭韓式簡寫 */
let arrowCat = name => ` 我的貓貓叫 ${name} `
console.log (cat('Miu'))
	// " 我的貓貓叫 Miu "
```
看得出來差在哪嗎？
把參數 name 的小括號拿掉惹。

但要注意 只有一個參數時、才能把小括號拿掉喔。
啊如果今天沒有參數時、小括號還是要裝上去 ! 



問題
---
試著用箭頭函式寫寫看 forEach 吧！
```javascript=
let pokemon = ['呆呆獸','沼王','噴火龍','雷丘']

pokemon.forEach(function(item,index){
 console.log(`${index+1} : ${item}`);
})
```


回報流程
---
將答案寫在 CodePen 並複製 CodePen 連結貼至 thread 中回報就算完成了喔! 解答請參考下圖（需打開程式碼的部分觀看）

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

<!-- 解答
https://codepen.io/xxRinRinxx/pen/zYzYLqw
-->

|      Slack       |       CodePen       |
|:----------------:|:-------------------:|
|   Karen Huang    |  https://codepen.io/Coding_Snorlax/pen/PoKMWoV |
| 蔡明達 | https://codepen.io/bmzpfyxe/pen/NWgKQZB?editors=0011 |
|    Iris Huang    |    https://codepen.io/ythuang/pen/xxLvgqp    |
|CloThEs | https://codepen.io/bogwdnxx-the-sans/pen/GRvVrme|
|    米米   |   https://codepen.io/Jameshsu0407/pen/rNzXjGw?editors=0011   |
|Aaron Tu|https://codepen.io/aarontu/pen/bGrXgoN|
| POPEYE | https://codepen.io/popeye_ux/pen/KKvOaXM |
|kk|https://codepen.io/potatokaka/pen/GRvVrvL?editors=0012|
Tim Lin|https://codepen.io/TimmyLin/pen/YzxmNaB
| Sam | https://codepen.io/sam-hsu/pen/GRvVrGb |
| 傅劍軒 | https://codepen.io/seonkuraito/pen/bGrXgKV?editors=0012 |
|群嘉|https://codepen.io/pen/?editors=1111|
|lumei|https://codepen.io/l_umei/pen/vYJoxEB|
| 連小艾 | https://codepen.io/bolaslien/pen/XWavMWY?editors=0012 |
| Jun Ting Lin | https://codepen.io/jake1155/pen/QWMepyg |
|有廖先生(Rain)|https://codepen.io/billpop741/pen/GRvVWKg|
| Elaine Liu | https://codepen.io/elaine7598/pen/JjygEVm?editors=0010 |
| Bean Huang | https://codepen.io/Beanhuang/pen/QWMeppq?editors=0011 |
| YC | https://codepen.io/YCLu/pen/jOLgBqL |
|大衛|https://codepen.io/exnsrpjc/pen/QWMepBQ?editors=0011|
|Arista|https://codepen.io/arista-hsieh/pen/JjygWmP|
|洋蔥|https://codepen.io/oikdkmxq-the-looper/pen/OJjKpBg?editors=1011|
| Kelvin Hsu | https://codepen.io/kelvin001/pen/OJjKpag |
|張喆|https://codepen.io/wow767t/pen/PoKMmRa|
|吉兒| https://codepen.io/Jillkate/pen/ZEJgKqG |
| Bella Shya | https://codepen.io/BellaXie/pen/ExvqmGN?editors=0011 |
|Calon|https://codepen.io/Calon0118/pen/zYdgwbK|
|Phil |https://codepen.io/ctkeftjp-the-animator/pen/GRvVEoP?editors=1111|
|Gill |https://codepen.io/Gill-Chin/pen/abyeWZO?editors=0011|
|陳暐中 |https://codepen.io/wei-z/pen/BadXZej?editors=0012|
| Yunei | https://codepen.io/Yunei/pen/eYEqEmM |
|AKI|https://codepen.io/akichen27/pen/xxLvLbQ|
| Steven Chan |https://codepen.io/Steven1220/pen/xxLvLLe?editors=1011 |
| Louis | https://codepen.io/Louis164156/pen/mdMNqdG?editors=1111 |
| Bonnie | https://codepen.io/bonnieli1414/pen/gOxVoyW?editors=1111 |
| Trista | https://codepen.io/trista6140/pen/mdMNXmB|
| ZY Hsu | https://codepen.io/zihyin/pen/wvqVmGb?editors=1011|
|Jasper|https://codepen.io/li-jasper/pen/JjrPXZK
|雪莉| https://codepen.io/utshang216/pen/PoJYKBz|
| YuriT | https://codepen.io/wenfisht/pen/bGobQoy |
|Jocelyn|https://codepen.io/enjoyful/pen/RwLbExb?editors=0010|
| Lai | https://codepen.io/co_lai/pen/wvrwOqO?editors=1011 |
| 小K | https://codepen.io/kelen1995/pen/poWzYpJ |
| Yashien Lin | https://codepen.io/YashienLin/pen/wvrwOvY?editors=1011 |
|Gui|https://codepen.io/guitimliu/pen/jOGNdjJ|
| 劉維倫 | https://codepen.io/lun0223/pen/oNGvOJr?editors=0011 |
| Peter Chen| https://codepen.io/yuckugjy-the-sasster/pen/rNGNxvd?editors=1112 |
|鄭安志|https://codepen.io/lwmtsgek/pen/ZEXEaXG?editors=1011|
|danny123|https://codepen.io/binlandz123/pen/vYeYRba?editors=0011 |
|Genos|https://codepen.io/pb220416/pen/OJxJEQj|
| Riley |https://codepen.io/jjpxbprd/pen/mdBdaxN |
|PeggyTsai|https://codepen.io/pei-chi-tsai/pen/gOGbLqW?editors=0011|
paul|https://codepen.io/xxRinRinxx/pen/zYzYLqw|
|YOYO|https://codepen.io/lumedkle/pen/KKXpzLR?editors=0011|
|Alvin|https://codepen.io/Alvin20201116/pen/NWaqmqo?editors=1111|
|Sandy|https://codepen.io/Sandy_L/pen/QWqjaPw?editors=0011|
| ZOE WU | https://codepen.io/Zoechiueh/pen/poWjGzg |
|kailun| https://codepen.io/Kailun/pen/jOGWzxZ |
|LTL| https://codepen.io/ltlin93/pen/oNGLeVz |
|許閔翔| https://codepen.io/oupbzfxq-the-scripter/pen/eYGdzoV?editors=1012 |
|Hamaji| https://codepen.io/hamajibashi/pen/VwMmRoV |
|Clara|https://codepen.io/ClaraChen/pen/XWepKdX?editors=1011|
|傑瑞| https://codepen.io/auatwood909815/pen/NWapzoX?editors=0012 |
