---
# System prepended metadata

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

---

# 🏅 Day 17 - 函式觀念二

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

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

可參考課程影音「函式 function - 函式裡面仍可以執行函式」章節

```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 / 答案 |
| --- | ----- | ----- |
| 01 |泊岸 | [CodePen](https://codepen.io/qoq77416416/pen/QWevNzY?editors=0011) | 
|02|voke|[CodePen](https://codepen.io/FiSi-the-lessful/pen/RwXpNKP)|
| 03    |  雪粒     | [CodePen](https://codepen.io/bzykdfhw-the-bashful/pen/KKOXPoy) | 
| 04    |  david1819     | [CodePen](https://codepen.io/David-Lin-the-vuer/pen/PoMJYXb) | 
| 05    |  tim   | [CodePen](https://codepen.io/jskrtivy-the-animator/pen/ZEgXzVM?editors=0011) | 
|06|邵|[CodePen](https://codepen.io/ukscrlno-the-typescripter/pen/PoMJYVW?editors=0012)|
|07|Jainee|[CodePen](https://codepen.io/Jainee0110/pen/NWQaWGy)|
| 08 | 毛巾 |[CodePen](https://codepen.io/bqdcjboa-the-solid/pen/QWeqWvV)|
|09|Hailey|[CodePen](https://codepen.io/sxbokfja-the-flexboxer/pen/ExqwxpV?editors=0012);
|10|陳睿睿|[CodePen](https://codepen.io/uwmrsusb-the-solid/pen/RwXLNGJ?editors=0011)|
| 11 | yuyuhunter_0509 | [CodePen](https://codepen.io/KRcube/pen/LYwzEaB?editors=0011) | 
| 12 | Ruby | [CodePen](https://codepen.io/xivgaijl-the-selector/pen/RwXLPwm) |
|  13   |   Ariel    | [CodePen](https://codepen.io/ariel0510/pen/WNVZvrG?editors=0011) |
|  14   | Lotte | [CodePen](https://codepen.io/hmkdoxuj-the-decoder/pen/poMWJbw?editors=0011)|
|  15   | Kaya | [CodePen](https://codepen.io/kayaribi/pen/KKOXdEL?editors=0011)|
|  16   | kaka_945 | [CodePen](https://codepen.io/kay945/pen/yLmzeyL)|
|17|mercury2508.| [CodePen](https://codepen.io/Mercury2508/pen/oNKGbeE) |
|  18   |    Celine   | [CodePen](https://codepen.io/szuning/pen/eYqGZoP) | 
| 19 | GTR150 | [CodePen](https://codepen.io/Wer-Qwe/pen/WNVZxRJ) | 
| 20 | yuyeh_1212 | [CodePen](https://codepen.io/yuyeh1212/pen/NWQarOO) |
| 21 | jimmy.0706 | [CodePen](https://codepen.io/JimmyMao/pen/OJKxXdE?editors=0012) |
| 22 | JRz | [CodePen](https://codepen.io/JRZHENG/pen/ZEgXOdE?editors=1111) |
| 23 |是在哈囉 | [CodePen](https://codepen.io/miyxdhem-the-solid/pen/eYqGdWz?editors=1111) |
| 24 |brucelee0629| [CodePen](https://codepen.io/xxhdklwi-the-decoder/pen/KKOXgYM?editors=0012) | 
| 25 |Rogan| [CodePen](https://codepen.io/RoganHsu/pen/wvVroXg) | 
| 26 | Mos | [CodePen](https://codepen.io/mos25399/pen/xxvXRBe?editors=0010) |
| 27 | Darius | [CodePen](https://codepen.io/bekgnohe-the-selector/pen/VwoMPPj?editors=0011) |
| 28 |yuling  | [CodePen](https://codepen.io/yu-ling-peng/pen/MWNEJzM?editors=0012) |
| 29 |嚼勁先生  | [CodePen](https://codepen.io/James520284/pen/gOVGmbK) |
| 30 |Mike  | [CodePen](https://codepen.io/mike2049/pen/KKOXWod?editors=0010) |
|  31   |    JIA   | [CodePen](https://codepen.io/nzaicwlw-the-styleful/pen/ExqwmdG?editors=0010) | 
|  32   |    Sonia   | [CodePen](https://codepen.io/YUJOU/pen/GRVMmQJ?editors=0011) | 
|  32  |    ycl325.etheddie   | [CodePen](https://codepen.io/wdvikfuz-the-selector/pen/bGXoRqL) | 
|  33  |    ABow_Chen   | [CodePen](https://codepen.io/fred39392001/pen/oNKGqBj) | 
| 34 | Dolce_墨 | [CodePen](https://codepen.io/DolceTseng1026/pen/wvVrjgN) | 
| 35 | haojing | [CodePen](https://codepen.io/hjxu/pen/wvVrYEo) | 
|   36  |   KUN.    | [CodePen](https://codepen.io/barry91205/pen/VwoMgYV) | 
|  37  | yaoling.liang | [CodePen](https://codepen.io/Yao-Ling-L-/pen/WNVZqVY?editors=1011) | 
|  38  | ab567ab5 | [CodePen](https://codepen.io/WanTzu-Chiang/pen/MWNOevP?editors=0012) |
|39|陳小廷| [CodePen](https://codepen.io/ting1124/pen/VwormBO) | 
|  40   |   610    | [CodePen](https://codepen.io/YI-LING-LIU/pen/bGXYYdq) | 
|  41   |   joylu0902    | [CodePen](https://codepen.io/joylu0902/pen/JjgOLjz) | 
|42|a1phaki(小k)|[CodePen](https://codepen.io/a1phaki/pen/vYoWVYz?editors=0011)
| 43    | Joannehu  | [CodePen](https://codepen.io/nelbabkv-the-flexboxer/pen/KKOyEqQ?editors=1111) | 
| 44    | alec1203  | [CodePen](https://codepen.io/soloayaya/pen/XWvzLjx?editors=1112) | 
|  45   |   Emma    | [CodePen](https://codepen.io/Emma0919/pen/PoMEzdp) | 
|46|ABOOS| [CodePen](https://codepen.io/guhungyin/pen/dyxJprZ?editors=0012) |
|  47  | jerry_66983 | [CodePen](https://codepen.io/Barry-C/pen/mdNpRRe?editors=0012) | 
|  48   |chris       | [CodePen](https://codepen.io/chris-chen-the-selector/pen/mdNpRxE?editors=0012) |
|  49   |  Jack     | [CodePen](https://codepen.io/kxbhixte-the-sasster/pen/dyxJJMp?editors=1111) |
|  50   |Seris| [CodePen](https://codepen.io/Dale-Chien/pen/eYqywYe) |
| 51 | Jim | [CodePen](https://codepen.io/JimChou/pen/GRVybrg?editors=0011) |
| 52 | Glen_69515 |[Codepen](https://codepen.io/glenyaochih/pen/ExqQQrw?editors=1111)|
| 53 | GAVI |[Codepen](https://codepen.io/qbafldcv-the-scripter/pen/gOVGYyL?editors=0010)|
|54|Tatsu| [CodePen](https://codepen.io/chindesu0207/pen/JjgvJWM) | 
|55|Yen| [CodePen](https://codepen.io/yuxxxlouyen/pen/eYqryLQ?editors=0010) | 
|56|Hedwig| [CodePen](https://codepen.io/adirehfz-the-encoder/pen/KKOePeE?editors=1011) | 
|57|野鴿| [CodePen](https://codepen.io/HoshinoSyouta/pen/bGXKaOW?editors=0011) |
|58|Ed Huang| [CodePen](https://codepen.io/yide1986/pen/rNXrxNm) |
|59|蘑菇星星| [CodePen](https://codepen.io/brrrieon-the-vuer/pen/NWQBdeQ?editors=0012) |
|60|charlottelee| [CodePen](https://codepen.io/char849/pen/wvVxPgY) |
|61|zobody| [CodePen](https://codepen.io/Zoe-Shih/pen/dyxqxRe) |
|62|iamcan| [CodePen](https://codepen.io/uhnxswdq-the-typescripter/pen/XWvxVQa) |
|63|KOMATSU PEI| [CodePen](https://codepen.io/Komatsu2021/pen/WNVYzKJ?editors=0012) |
|64|Nocab| [CodePen](https://codepen.io/PeihanWang/pen/BaXMYMX?editors=0011) |
|65|Amy(咂摳)| [CodePen](https://codepen.io/nnxucgmc-the-builder/pen/jOgJLQv?editors=0010) | 
|66|Satar| [CodePen](https://codepen.io/SatarKuo/pen/MYgmWOV?editors=0011) | 
|67|Chuang|[CodePen](https://codepen.io/uidoytjq-the-solid/pen/WbezYOd)

<!-- 可複製下方格式
|     |       | [CodePen]() | 
-->

