---
# System prepended metadata

title: "\U0001F3C5 Day 17 - 函式觀念二"
tags: [JS 直播班 - 2022 秋季班]

---

---
tags: JS 直播班 - 2022 秋季班
---
# 🏅 Day 17 - 函式觀念二

依照下方程式碼練習，並回答問題。

### 函式裡面仍可以執行函式 

[課程影音連結](https://courses.hexschool.com/courses/202011131/lectures/42391124)

```javascript=
function dailyAction() {
  cleanHead();
  console.log("出門");
  console.log("回家");
  cleanHead();
} 
function cleanHead() {
  console.log("刷牙");
  console.log("洗臉");
} 
dailyAction();
```
> 函式內部可以呼叫其他函式，
> 可以重複利用程式碼、簡潔版面。

問題
---
1. 觀看以下程式碼，利用函式觀念二，嘗試優化 `todayTask()` 函式
```javascript=
function todayTask() {
  console.log("觀看課程");
  console.log("製作筆記");
  console.log("每日任務");
  console.log("觀看課程");
  console.log("製作筆記");
  console.log("主線任務");
  console.log("觀看課程");
  console.log("製作筆記");
}
function watchAndNote() {
  console.log("觀看課程");
  console.log("製作筆記");
}
```
2. 觀看以下程式碼，最後會印出什麼
```javascript=
function printNumbers() {
  printOne();
  console.log("11");
  printOne();
}
function printOne() {
  console.log("1");
}
printOne();
```




## 回報流程

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

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

<!-- 解答：  

1. 
```
function todayTask() {
  watchAndNote();
  console.log("每日任務");
  watchAndNote();
  console.log("主線任務");
  watchAndNote();
}
function watchAndNote() {
  console.log("觀看課程");
  console.log("製作筆記");
}
```

2. 1
   （原因：printNumbers() 沒有呼叫！）
-->




回報區
---


|   Discord    |                    CodePen / 答案                      |
|:----------:|:-------------------------------------------------------:|
| masterYan#2480 | [CodePen](https://codepen.io/htzwgoqt-the-looper/pen/YzvzqZQ?editors=1011) |
| YC#2522 | [CodePen](https://codepen.io/YCLu/pen/ZERzXoQ) |
| Cliff#4606 |[Codepen](https://codepen.io/Cliff_hex/pen/mdKdeyQ)|
|hsiung阿熊#4079|[Codepen](https://codepen.io/hsiungchi/pen/oNyNjXq)|
|Data#9297|[Codepen](https://codepen.io/kirakira72/pen/GRGRppP)|
|albee#9121|[Codepen](https://codepen.io/albee-chang/pen/vYrYNLV?editors=1012)|
|Lucie#3831|[Codepen](https://codepen.io/bisespei/pen/OJEJyNY)|
|DaisyLi#4231|[Codepen](https://codepen.io/lidairong-gmail-com/pen/QWxWjEb?editors=0012)|
|AuroraC#6539|[codepen](https://codepen.io/AuroraC/pen/rNKNOMm?editors=1012)|
|Hazel.#6020|[Codepen](https://codepen.io/Hazelhsieh/pen/jOxgOjx?editors=1111)|
|Data#9297|[Codepen]
|Arista#5802|[Codepen](https://codepen.io/arista-hsieh/pen/BaVaoQX)|
|VT#0895 | [Codepen](https://codepen.io/vt197/pen/ZEREbee)|
|jimmyFang#9575 | [Codepen](https://codepen.io/pohxiqqo/pen/WNyNQjQ?editors=0010)|
|無名#6427 | [Codepen](https://codepen.io/Nomoney/pen/bGKGVWN?editors=0010)|
|Clara#1275 | [Codepen](https://codepen.io/bsupixqu/pen/xxzxwdY)|
|薯餅#3581 | [Codepen](https://codepen.io/ColdingPoTaTo/pen/OJEJypK)|
|yumy#1940 | [Codepen](https://codepen.io/yumy_yamg/pen/OJEJyzL)|
|楓之聲#6945|[Codepen](https://codepen.io/sshane258/pen/yLELYpg)|
|末次#0236|[Codepen](https://codepen.io/yunjulee/pen/JjZjYMZ)|
|予予#9627|[Codepen](https://codepen.io/kiqzcraa/pen/QWxWjrE?editors=1111)|
|IreneY#0086|[codepen](https://codepen.io/HalfPlannedJourney/pen/zYaYvaR)|
|KatyChiang#1554|[codepen](https://codepen.io/Kai0819/pen/LYrYprg?editors=0011)|
|君Jyun#0147|[codepen](https://codepen.io/Okaybeok/pen/bGKGVKE?editors=0011)|
|Benson#6763|[Codepen](https://codepen.io/kumashow/pen/PoaoPBo)|
|母湯#7211|[Codepen](https://codepen.io/tommyshih77/pen/ZEREbMX?editors=0011)|
|Ayre#0016|[CodePen](https://codepen.io/yichunlin09/pen/vYrYNaM?editors=0010)|
|YI#0863|[CodePen](https://codepen.io/YI0305/pen/RwJwWYz?editors=0011)|
|心幻羽#0056|[CodePen](https://codepen.io/linglingsyu/pen/QWxWjJG?editors=1111)|
|Chung#5951|[CodePen](https://codepen.io/yuju16/pen/MWXWaxE?editors=0010)|
|CloThEs#7837|[CodePen](https://codepen.io/CloThEsZ/pen/GRGRpdV)|
|hannahTW#2224|[CodePen](https://codepen.io/hangineer/pen/OJEJMJN?editors=0011)|
|JackC#0411|[CodePen](https://codepen.io/key0329/pen/eYKYJpr)|
|Hironaka#7367|[CodePen](https://codepen.io/Hironaka0815/pen/xxzxZOM?editors=0010)|
|法希娜#3206|[CodePen](https://codepen.io/yiiserpf-the-encoder/pen/bGKGEBW?editors=0011)|
|威爾#1694|[CodePen](https://codepen.io/WILL_Wu/pen/ExRxPbM)|
|yoshidc#0455|[CodePen](https://codepen.io/yoshiyyc/pen/Yzvzwew)|
|amy芳#1385|[CodePen](https://codepen.io/amy-chieng/pen/eYKYJjb)|
|William Lai#0196|[CodePen](https://codepen.io/lai-weihan/pen/yLELeRR)|
|圈圈#4060|[Codepen](https://codepen.io/wjejczn-the-bold/pen/WNyNrYz)
|homer#1525|[Codepen](https://codepen.io/Buckhorn/pen/GRGRoQN)
|Hilda#7085|[Codepen](https://codepen.io/vwquikad-the-vuer/pen/yLELeQR)
| Jenny真#7532 | [CodePen](https://codepen.io/wei-chen-wu/pen/LYrYNEN?editors=0010) |
|kuku#3118|[Codepen](https://codepen.io/mengting-ku/pen/dyKyMMN)
|Ruby Chen#7452|[Codepen](https://codepen.io/ruby92429/pen/yLELOgW?editors=0011)|
|威0#6919|[Codepen](https://codepen.io/n0918679182/pen/rNKNema?editors=0012)|
|Loran#1105|[Codepen](https://codepen.io/loranlin/pen/bGKGpWm?editors=1011)|
|艸良#2846|[Codepen](https://codepen.io/momoninainai/pen/qBKBZPR?editors=0010)|
|Yiru#0236|[Codepen](https://codepen.io/yiru94/pen/ExRxPeB?editors=0011)|
|JustinLiu#9699|[CodePen](https://codepen.io/justin0227/pen/eYKYZjp?editors=0011)|
|Potatolee#7749|[CodePen](https://codepen.io/potatoleee/pen/dyKyMxd?editors=0010)|
|柔柔#1716|[Codepen](https://codepen.io/rouchen/pen/XWYWKJp?editors=0011)|
|泰泰泰泰#0582|[Codepen](https://codepen.io/tesdzzph-the-bashful/pen/VwdwjPG?editors=0010)|
|Greta#0837|[CodePen](https://codepen.io/gretali/pen/QWxWEKb)|
|Winnie#1306|[Codepen](https://codepen.io/WinnieWuWinnie/pen/MWXWeVm?editors=0011)|
|RJRS#9430|[CodePen](https://codepen.io/RJRS/pen/oNyNLaJ)|
|shinyhung#3825|[CodePen](https://codepen.io/sean_1215/pen/BaVazgK?editors=0010)|
|大衛#4869|[CodePen](https://codepen.io/exnsrpjc/pen/jOKOroB?editors=0011)|
|Mylène#2481|[Codepen](https://codepen.io/hamajibashi/pen/VwdwjoO)|
|PayRoom#8328|[CodePen](https://codepen.io/water38198/pen/gOKOwgM)
|Rena#6249 |[Codepen](https://codepen.io/aureate0116/pen/WNyNGpE?editors=1010)
|教練#6451|[Codepen](https://codepen.io/monkeybear721/pen/jOKOMLY)|
|Judy☻ #7874|[CodePen](https://codepen.io/hsiaohan/pen/YzvzGey?editors=0010)|
|肉桂卷#0625|[CodePen](https://codepen.io/ginnlee/pen/PoaoGdm?editors=0011)|
|k.sin#3115|[Codepen](https://codepen.io/sin588/pen/jOKOMdK?editors=0011)|
|雷雷#7844|[Codepen](https://codepen.io/lei-yi-jie/pen/OJEJbpZ?editors=0010)|
|banazita#5143|[CodePen](https://codepen.io/banazita/pen/BaVaQxq?editors=1111)|
|Paul#7426|[CodePen](https://codepen.io/paul-1997/pen/YzvzpOY?editors=0010)|
|勁辣雞腿寶#5817|[CodePen](https://codepen.io/orz311013/pen/wvXvobO?editors=1011)|
|jackson204#6363|[CodePen](https://codepen.io/jackson204/pen/BaVapoe?editors=1111)|
|出事了阿伯#9923|[CodePen](https://codepen.io/BradpittLai/pen/OJEJbKd?editors=1011)|
|kenki100#0068|[codepen](https://codepen.io/ken100/pen/abKbpmL)|
|cotton#7163|[codepen](https://codepen.io/cottonT/pen/WNyNRob?editors=0010)|
|mandylai#4055|[codepen](https://codepen.io/mandy-lai-2/pen/xxzxqbQ)|
|jacky010080#0880|[CodePen](https://codepen.io/Yen-Jung-Chen/pen/abKbJjg?editors=0010)|
|我是泇吟#5189|[CodePen](https://codepen.io/kljuqbxs/pen/gOKOmqW)|
|Amberhh#2465| [Codepen](https://codepen.io/Amberhh/pen/jOKObmq?editors=0010) |
|yawun#0042|[CodePen](https://codepen.io/monicalin/pen/vYrYmEx)|
|SASIMI#5099|[Codepen](https://codepen.io/sashimi1327/pen/RwyYZBZ)|
|  cbs#9007  |[Codepen](https://codepen.io/wasdjk/pen/xxzxdLO)|
| 哈囉哈#5196 |[CodePen](https://codepen.io/bill0841205/pen/zYaYwRr?editors=1011)|
| Yuna Huang#2692 |[CodePen](https://codepen.io/Yuna1002/pen/vYrYmpW?editors=0010)|
|萱仔#0781|[CodePen](https://codepen.io/ting-hsuan/pen/vYrYmjp?editors=0010)|
|mou#2215|[CodePen](https://codepen.io/shihchiehlan/pen/KKeKmYP?editors=0010)|
|yoyo#1003|[CodePen](https://codepen.io/crpbugqy-the-typescripter/pen/BaVaRgM?editors=1111)|
|yen#5757|[CodePen](https://codepen.io/TZU-HUANG-YEN/pen/oNdPgqY?editors=0011)|
|Ohno#1144|[Codepen](https://codepen.io/mmaa7850/pen/VwdwWYx?editors=0011)
|RayChen#6088|[Codepen](https://codepen.io/raychen1996/pen/oNyNwZy)|
| 小白#2406 | [CodePen](https://codepen.io/gracewhite/pen/abKbJVx) |
|Sentiments#4883|[codepen](https://codepen.io/Sentiments/pen/NWzWvKb?editors=0010)
|poetry1933#2713|[codepen](https://codepen.io/poetry1932/pen/qBKBPma?editors=0010)
| LHchien33#6232 |[codepen](https://codepen.io/lin_chien/pen/VwdwMWb?editors=0010)
|WEI_RIO#9342|[codepen](https://codepen.io/wei_wu/pen/zYaYEbK?editors=0011)|
|竹輪#3335|[codepen](https://codepen.io/chikuwa0120/pen/NWzWwrK)|
|ling chang#1024|[codepen](https://codepen.io/ling-chang/pen/bGKGYEP)|
|Ron Liang#7277|[codepen](https://codepen.io/ron-go/pen/JjZjMRx)|
| 黃士桓#7654 | [codePen](https://codepen.io/shr-huan-huang/pen/ExRxQWj) |
| 蓁心#6229 | [codePen](https://codepen.io/tlorfrnl-the-typescripter/pen/WNyNMyP?editors=1011) |
| CofCat#9226 | [codePen](https://codepen.io/cofcat456/pen/bGKGvQV) |
|FiReBrO #0557|[Codepen](https://codepen.io/firebro42/pen/PoaqmyO)|Eileen#6454https://codepen.io/Eileen-io/pen/VwdLMLwhttps://codepen.io/firebro42/pen/PoaqmyOhttps://codepen.io/Eileen-io/pen/VwdLMLw
| 安o#2448 | [codePen](https://codepen.io/JzhenAn/pen/VwdLgVj) |
| kevin #6131 | [codePen](https://codepen.io/xlqjezvc-the-encoder/pen/dyKoaBp?editors=0010) |
|sophie#7015|[Codepen](https://codepen.io/sophiee2727/pen/PoaqVrO?editors=1010)|
|富#0389|[Codepen](https://codepen.io/spring40747/pen/qBKdGBv?editors=1112)|
|YU#0618|[Codepen](https://codepen.io/yoken_/pen/JjZYKxJ)|
|PoWei#8484|[Codepen](https://codepen.io/harrison-wei-lai/pen/QWxjKQN?editors=1111)|
|Chloe#5422|[Codepen](https://codepen.io/Ironchloe/pen/PoaPKzL?editors=0010)|
|Ringo#7583|[Codepen](https://codepen.io/ringolai1988/pen/NWzGvzx?editors=0010)|
|Jhen#4563|[Codepen](https://codepen.io/su-jhen/pen/BaVodej)|
|Shuo#1596|[Codepen](https://codepen.io/chiangchungshuo/pen/YzvyrOw?editors=1111)|
|郭芙蘭#6374|[Codepen](https://codepen.io/flora_Kuo/pen/vYrNWxZ?editors=0011)|
|Peng#9811|[Codepen](https://codepen.io/peng-027/pen/jOKbxzq)|
|shio#1414|[Codepen](https://codepen.io/shioyen/pen/abKvXGM?editors=1111)|
|bingsu#2362|[Codepen](https://codepen.io/pmyfr/pen/xxzweJW?editors=0010)|
|yaru#6308|[Codepen](https://codepen.io/lszaietc/pen/JjZoQJJ)|
|Velma#1693|[Codepen](https://codepen.io/Ze1225/pen/ExRPWro?editors=0010)|
|How#5806|[Codepen](https://codepen.io/howtobefine/pen/ZERQMPe)|
|mei#8421|[Codepen](https://codepen.io/Shila-Chen/pen/eYKJazG?editors=0010)|
|yuling#1634|[codepen](https://codepen.io/igzdflpu/pen/poKyNMa)|
|kancheng#3915|[CodePen](https://codepen.io/kancheng/pen/wvXGgZX?editors=0111)|
|Nini Chen#5790|[CodePen](https://codepen.io/ninistyle/pen/eYKZVbM?editors=0012)|
|阿蘇#8531|[CodePen](https://codepen.io/susu3131/pen/BaVKVvK?editors=0011)|
|軟綿綿 (๑•ᴗ•๑) ♡#3627|[CodePen](https://codepen.io/Connie-Chien/pen/NWzNBGg?editors=0011)|
|三隻小貓#1905|[CodePen](https://codepen.io/bagelover/pen/RwJaBgR?editors=1010)|
|Azi Hsieh#2861|[CodePen](https://codepen.io/AziHsieh/pen/eYKZPmg)|
|Cynthia1111#1822|[CodePen](https://codepen.io/Cynthia1111/pen/ExRyvQK)|
|Tuhacrt#0008|[codepen](https://codepen.io/Tuhacrt/pen/vYrKwEj)|
|Cream#3449|[codepen](https://codepen.io/frxdwbbi-the-sasster/pen/oNyzBqr?editors=0011)|
|L0F0#8733|[codepen](https://codepen.io/l0f0/pen/abKBVvE?editors=0010)|
|Lou#0085|[codepen](https://codepen.io/Lusie_H/pen/dyKOaOW?editors=0011)|
|H.L.C#2152|[Codepen](https://codepen.io/hsin-liang/pen/bGKRdQL)|
|meimei#9524|[Codepen](https://codepen.io/isnrudav/pen/abKyrMX)|
|yuchenye#6119|[Codepen](https://codepen.io/yuchen/pen/ZERXbBm)|
|Baozi#2042|[Codepen](https://codepen.io/lillianyu/pen/wvXpvXd)|
|pss940909#8650|[Codepen](https://codepen.io/pss940909/pen/yLEpwMo?editors=1011)|
|samger#0808|[Codepen](https://codepen.io/lee-wei-hong/pen/xxzmMrr?editors=1111)|

