---
# System prepended metadata

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

---

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

函式觀念四
---
建議同學都將以下程式碼貼入 CodePen 執行、觀察結果。



### 函式的 return 觀念 ([參考章節1](https://courses.hexschool.com/courses/20201113/lectures/34094713)、[參考章節2](https://courses.hexschool.com/courses/20201113/lectures/34094716))
１. 函式可以用 return 回傳一個值，並可以將該值賦予給其他變數。
```js=
function calcTotalScore(chineseScore, englishScore){
    let total = chineseScore + englishScore;
    return total;
}

// 將 calcTotalScore 的回傳值賦值給 markScore。
let markScore = calcTotalScore(60, 50);
console.log(markScore);
```

2. return 會中斷函式執行，可以有多個 return、搭配 if else 做使用。
```js=
function calcTotalScore(chineseScore, englishScore){
    let total = chineseScore + englishScore;
    
    // 在此因為 total > 100，所以在第一個 if 函式就中斷了
    if(total > 100){
        return `總分 ${total}，做的好啊 mark`;
    }else{
    	return `總分 ${total}，考得不是很好 mark`;
    }

    // 以下的 return 都不會執行
    return chineseScore;
    return englishScore;
}

let markScore = calcTotalScore(60, 50);
console.log(markScore);
```

問題
---
請親自撰寫一次以上觀念的程式碼，並可以用註解強化知識點。


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

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

|    Slack     |                         CodePen                          |
|:------------:|:--------------------------------------------------------:|
| Karen Huang  |      https://codepen.io/Coding_Snorlax/pen/VwzQrZL       |
|   CloThEs    |     https://codepen.io/bogwdnxx-the-sans/pen/bGrLYWL     |
|    jojoy     |    https://codepen.io/jojoy/pen/poradrQ?editors=0011     |
|   Tim Lin    |   https://codepen.io/TimmyLin/pen/ZEJraJP?editors=1111   |
|   Aaron Tu   |          https://codepen.io/aarontu/pen/xxLYPpG          |
|      YC      |           https://codepen.io/YCLu/pen/rNzJYzg            |
|    傅劍軒    | https://codepen.io/seonkuraito/pen/abyqVRv?editors=0010  |
|  Iris Huang  |          https://codepen.io/ythuang/pen/eYEVeXY          |
|    劉維倫    |   https://codepen.io/lun0223/pen/jOLZaKQ?editors=1011    |
|  Andy Huang  |        https://codepen.io/HsuHuaHuang/pen/qBXxVwq        |
|    林小君    |     https://codepen.io/hcvbcjqq-the-vuer/pen/zYdRpOr     |
|     Gill     |  https://codepen.io/Gill-Chin/pen/PoKQOVR?editors=0011   |
|  Peter Chen  |   https://codepen.io/yuckugjy-the-sasster/pen/VwzQyar    |
| Jun Ting Lin |         https://codepen.io/jake1155/pen/ExvQoxy          |
|    POPEYE    |         https://codepen.io/popeye_ux/pen/mdMXpVL         |
|     Lai      |    https://codepen.io/co_lai/pen/WNEMdZV?editors=0011    |
|     Sam      |          https://codepen.io/sam-hsu/pen/WNEMXYY          |
|    蔡明達    |         https://codepen.io/bmzpfyxe/pen/NWgKQZB          |
|    Genos     |         https://codepen.io/pb220416/pen/dyzdJqK          |
|    lumei     |          https://codepen.io/l_umei/pen/dyzdJQj           |
|     大衛     |   https://codepen.io/exnsrpjc/pen/WNEMXBL?editors=0010   |
|     Sam      |          https://codepen.io/sam-hsu/pen/WNEMXYY          |
|    Arista    |       https://codepen.io/arista-hsieh/pen/VwzQyVG        |
|     米米     | https://codepen.io/Jameshsu0407/pen/OJjQzre?editors=0011 |
|  Elaine Liu  |  https://codepen.io/elaine7598/pen/MWvQrzb?editors=0010  |
|  有廖先生(Rain) |  https://codepen.io/billpop741/pen/OJjQOQz  |
|張喆|https://codepen.io/wow767t/pen/BadYYjN|
|AKI|https://codepen.io/akichen27/pen/OJjQQxM|
|Steven Chan | https://codepen.io/Steven1220/pen/vYJddJo?editors=1011 |
| Yunei | https://codepen.io/Yunei/pen/NWvyyJg |
| Tingyu | https://codepen.io/dgltu/pen/jOLZZQG?editors=0011 |
| Jie Du | https://codepen.io/qgqonost-the-flexboxer/pen/dyzddab?editors=0011 |
| Pei Ying | https://codepen.io/Pei-Ying/pen/xxLYWxo?editors=0011 |
| 許閔翔 | https://codepen.io/oupbzfxq-the-scripter/pen/NWvyYNX |
| ZY Hsu | https://codepen.io/zihyin/pen/mdMXxpw?editors=1011 |
|Anna|https://codepen.io/kycrleao/pen/MWvQGpw?editors=1011|
|阿和|https://codepen.io/shnny/pen/OJjQEBR?editors=0011|
|phi|https://codepen.io/aiya861202/pen/eYEmVjR?editors=1111|
|Louis|https://codepen.io/Louis164156/pen/abyqaWJ?editors=1010|
|  YOYO  |  https://codepen.io/lumedkle/pen/ExvQeyg?editors=0011  |
|  陳暐中  |  https://codepen.io/wei-z/pen/wvqyYzK?editors=0011  |
|  蔣秉彣  |  https://codepen.io/the-pierre/pen/bGrojWJ  |
| 黃士桓 | https://codepen.io/shr-huan-huang/pen/dyzdQyP?editors=0011 |
|喜美|https://codepen.io/Candace802/pen/oNeEQwb?editors=0010|
|lingxuan|https://codepen.io/penglingxuan/pen/eYEVQQq?editors=0110|
| Celeste | https://codepen.io/Celeste17/pen/YzxedyE?editors=0011 |
|Vicky Kao|https://codepen.io/vicky03035/pen/poraYxG|
|Sandy|https://codepen.io/Sandy_L/pen/xxLYNZj?editors=0011|
| Kelvin Hsu | https://codepen.io/kelvin001/pen/dyzmXQp |
|鄭安志|https://codepen.io/lwmtsgek/pen/jOLzajQ?editors=0011|
|洋蔥|https://codepen.io/oikdkmxq-the-looper/pen/eYEMXVb?editors=0011|
|Jasper|https://codepen.io/li-jasper/pen/OJjZywg|
|kevinhes|https://codepen.io/kevinhes/pen/rNzveOj?editors=0012|
|Yashien Lin|https://codepen.io/YashienLin/pen/YzxLqed|
|danny123| https://codepen.io/binlandz123/pen/GRvdQgY?editors=0010 |
|Irene Wang|https://codepen.io/irene-wang-the-looper/pen/OJjZKmz|
| ZOE WU  |    https://codepen.io/Zoechiueh/pen/xxLjveR?editors=0011     |
| Riley | https://codepen.io/jjpxbprd/pen/abyKoEL |
|  肉魚  |  https://codepen.io/zoechen13/pen/PoKaGPj  |
|Booker|https://codepen.io/bookbasketball/pen/xxLzXqd|
|柯勝華|https://codepen.io/Chill-Nick/pen/bGrKOXm?editors=0010|
|Mingyo|https://codepen.io/Nick-Yo/pen/LYjraZg?editors=0011| 
| LTL |https://codepen.io/ltlin93/pen/NWvByoQ |
|Gui|https://codepen.io/guitimliu/pen/YzxvZXq|
|zaii|https://codepen.io/ivy2846357/pen/oNeaXZL?editors=0010|
|鉦勝|https://codepen.io/atckmax823/pen/XWaxgwe?editors=0011'
|kailun|https://codepen.io/Kailun/pen/dyzgdvM'
|Alvin|https://codepen.io/Alvin20201116/pen/yLoQEJj?editors=0011|
|吐司|https://codepen.io/malolulu/pen/xxLMvEg|
|Ching|https://codepen.io/Jaimedede/pen/ZEJPmbR?editors=1010|
|paul|https://codepen.io/printfootya/pen/abyrWzB?editors=0011|
|傑瑞|https://codepen.io/auatwood909815/pen/ZEJNyYJ?editors=0011|
|Jean Chiang| https://codepen.io/jeanchiang1221/pen/xxLodmL|
|Zooey Cheng|https://codepen.io/noraneko0430/pen/GRvwNoq?editors=0010| 
|Zooey Cheng|https://codepen.io/noraneko0430/pen/GRvwNoq?editors=0010|
|Jeff|https://codepen.io/jeff-cheng/pen/RwLWdor?editors=0010|
|ShinyChen|https://codepen.io/shinychen/pen/mdBXrMJ|




