---
# System prepended metadata

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

---

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

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

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

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

```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 / 答案                            |
|:-------------:|:-------------------------------------------------------------------:|
|    pinyi_9    |    [CodePen](https://codepen.io/Wpypy/pen/jOdqeBL?editors=1011)     |
|   kuanju27    |        [CodePen](https://codepen.io/Eero-Chiao/pen/LYqNgyo)         |
|    hsu0921    |        [CodePen](https://codepen.io/HSUANIN0327/pen/rNPeqmr)        |
|   Chia Pin    |         [CodePen](https://codepen.io/joker-cat/pen/OJdNBQW)         |
| xiaokui_71292 |         [CodePen](https://codepen.io/pen?template=WNPwaJZ)          |
|    yuling     |         [Codepen](https://codepen.io/igzdflpu/pen/OJdNBZW)          |
|   ShangChu    | [CodePen](https://codepen.io/shangchu0412/pen/abXNRar?editors=0010) |
|     Ching     |  [CodePen](https://codepen.io/tzuchingg/pen/bGzpmQo?editors=0011)   |
|     Peng      |    [CodePen](https://codepen.io/H-Peng/pen/RwvaeER?editors=0010)    |
|    銀光菇     |       [CodePen](https://codepen.io/genesynthesis/pen/gOqrBmP)       |
|     Ivy      |      [CodePen](https://codepen.io/Irene-Ke/pen/YzBqJZK?editors=0010) |
|     yuan!    |      [CodePen](https://codepen.io/townyuan/pen/zYeqmVQ) |
| cest_jessie | [CodePen](https://codepen.io/itsjessiechen/pen/RwvaeQr) |
| runweiting | [CodePen](https://codepen.io/weiting14/pen/yLZOQgw) |
| Eden |[Codepen](https://codepen.io/iseden/pen/ExrKOwV)|
| Rxzan | [CodePen](https://codepen.io/Tzuru-Chen/pen/LYqNXOb) |
| CPing | [CodePen](https://codepen.io/CPing/pen/zYeqMWv) |
| zona | [CodePen](https://codepen.io/w242920/pen/XWOdywK?editors=1111) |
| MDFK | [CodePen](https://codepen.io/maywang/pen/vYbLMeP) |
| 小夏 | [CodePen](https://codepen.io/michaelhsia/pen/QWYNzwe) |
| Alyce | [CodePen](https://codepen.io/alycehwy/pen/wvNGRKZ?editors=0010) |
| 保羅 | [CodePen](https://codepen.io/paul-1997/pen/PoVNXPX?editors=0010) |
| yuan2781 | [CodePen](https://codepen.io/ismebir/pen/PoVNXqX) |
| hsiu8767 | [CodePen](https://codepen.io/hsiu8767/pen/WNPwLRN?editors=0011) |
| ming0712 | [CodePen](https://codepen.io/StevenHuang/pen/rNPeogp?editors=0010) |
| Hellen | [CodePen](https://codepen.io/milkteamonster/pen/VwgagaJ?editors=0010) |
| 依依| [CodePen](https://codepen.io/Rita-Yang/pen/eYxZxdM?editors=0011) |
|Moreene|[CodePen](https://codepen.io/Moreene/pen/zYeqeJe)|
| xin | [CodePen](https://codepen.io/Estherrrrrr999/pen/ExrKrOJ) |
| dora | [CodePen](https://codepen.io/dorayu/pen/gOqrqqg?editors=1011) |
| claire | [CodePen](https://codepen.io/yi-wen-chen/pen/dyaMaEY) |
| Winnie | [CodePen](https://codepen.io/codepen-io-winnie/pen/LYqNaYp?editors=0011)|
| 風羽 | [CodePen](https://codepen.io/Joy-Huang/pen/GRzZeMO?editors=0011)|
| 阿維#2569 | [CodePen](https://codepen.io/iijojpli-the-looper/pen/jOdqRjV?editors=0011)|
| kawa | [CodePen](https://codepen.io/z83xji6/pen/bGzpybp?editors=0010) |
| Lychee KK | [CodePen](https://codepen.io/kakakala/pen/KKJzLMq) |
| ann6212 | [CodePen](https://codepen.io/yqmegupa-the-styleful/pen/KKJzjKB?editors=1112) |
| 阿賀#3700 | [CodePen](https://codepen.io/sungho/details/PoVNrrd) |
| xuan| [CodePen](https://codepen.io/xuan0915/pen/vYbGqoR?editors=0012) |
| jimmy.0706| [CodePen](https://codepen.io/WeiJun-Mao/pen/qBgZeqV?editors=0010) |
| 凱恩| [CodePen](https://codepen.io/Royen0506/pen/ZEwWgxL?editors=1111) |
| 荷菓かのり | [CodePen](https://codepen.io/oogxwkvw-the-builder/pen/RwvaXvO?editors=0012)|
| 維哲 | [CodePen](https://codepen.io/kwz1202/pen/XWOdvwV) |
| 精靈 | [CodePen](https://codepen.io/justafairy/pen/dyaXbvB) |
| MY | [CodePen](https://codepen.io/ahmomoz/pen/yLZJBPv) |
| SHUO | [CodePen](https://codepen.io/xrzarxkl-the-reactor/pen/NWoNjdj?editors=1011) |
| hsuanlee1084 | [CodePen](https://codepen.io/hsuanlee1024/pen/eYxzYQm?editors=1010) |
| Joy chiang | [CodePen](https://codepen.io/fwysphbw-the-vuer/pen/OJdXPVr?editors=0010) |
| shiro | [CodePen](https://codepen.io/chenghsienwang/pen/eYxzmEB) |
| smalljie | [CodePen](https://codepen.io/smalljie/pen/JjxKomv) |
| yu.t_liu | [CodePen](https://codepen.io/YuT200053/pen/MWLewyO?editors=1111) |
| nini1202desu| [CodePen](https://codepen.io/tvxq5206/pen/wvNWaBM?editors=0011) |
| jiayu| [CodePen](https://codepen.io/fjqxaznl-the-reactor/pen/xxMOGYB?editors=0010) |
| Rogan| [CodePen](https://codepen.io/pen/?editors=0010) |
| JasonFu| [CodePen](https://codepen.io/jie-Fu/pen/BaMzoLJ) |
|Fabio20|[CodePen](https://codepen.io/fabio7621/pen/WNPxQmm)|
| Mattie | [CodePen](https://codepen.io/mattielin/pen/Exryyba) |
| 阿榮 | [Codepen](https://codepen.io/codeitaday/pen/xxMOrBE) |
| Andy | [Codepen](https://codepen.io/andy31342/pen/XWOKeeY?editors=0012) |
| damon0323 | [CodePen](https://codepen.io/swk9eny2/pen/bGzeoLg?editors=0011) |
| Ataraxia | [CodePen](https://codepen.io/ataraxia8888/pen/ZEwWOQd) |
| 奔跑吧(GTR150)) | [CodePen](https://codepen.io/Wer-Qwe/pen/QWYEmym?editors=1112) |
|gebyman| [CodePen](https://codepen.io/gebyman/pen/WNPxJGB?editors=0012) |
| santu0868 | [CodePen]([連結](https://codepen.io/HatsumiSan/pen/YzBWvwg)) |
| Vivian2857 | [CodePen]([連結](https://codepen.io/uojbohed-the-solid/pen/jOdyJYm)) |
|Uli| [CodePen](https://codepen.io/uli1313/pen/BaMzvwb?editors=0011) |
|Jerry| [CodePen](https://codepen.io/ildkosxk-the-encoder/pen/qBgNgNM) |
| phyllis |[CodePen](https://codepen.io/Phyllis-Cheng/pen/wvNzvZx)|
| tanuki5863 |[CodePen](https://codepen.io/tanuki320/pen/OJdRMWB?editors=1011)|
|Yijing|[CodePen](https://codepen.io/Yi-Jing-71080635/pen/oNmzboo?editors=0011)|
|⭐️小正|[CodePen](https://codepen.io/colorgolden/pen/jOdMWdP)|
|RX00|[CodePen](https://codepen.io/llqzknqv-the-styleful/pen/ZEwpWze?editors=0011)|
|davidtt|[CodePen](https://codepen.io/David-Tsai/pen/BaMLWWG?editors=0011)|
|白夜|[CodePen](https://codepen.io/Wei903/pen/GRzjWbz?editors=1010)|
|noah|[CodePen](https://codepen.io/lch1222/pen/mdvrmgJ?editors=0011)|
|歐陽龍龍#1061|[CodePen](https://codepen.io/dizzydog-rgb/pen/poGErdo)|
| 蛋塔| [CodePen](https://codepen.io/Hong-Game1/pen/VwgKGJd)|
| Sponge| [CodePen](https://codepen.io/biunpujm-the-flexboxer/pen/yLZaRQz?editors=1010)|
| 郭芙蘭#6374| [CodePen](https://codepen.io/flora_Kuo/pen/WNPGYqg?editors=1011)|
| Cosmos| [CodePen](https://codepen.io/violet7755/pen/WNPoQRE)|
| Tina02 | [CodePen](https://codepen.io/chjitlox-the-bashful/pen/GRzZEyx) |
| 小廷 | [CodePen](https://codepen.io/uyxkiake-the-selector/pen/wvNoxgo?editors=0010) |
|OSN|[Codepen](https://codepen.io/osncodepen/pen/rNPWrro?editors=1111)|
|hsuhsusophie|[Codepen](https://codepen.io/hsuhsusophie/pen/rNPWQwr?editors=0011)|
|Oria|[Codepen](https://codepen.io/kajing/pen/vYbyPRN?editors=0011)|
|Peggy|[Codepen](https://codepen.io/peggylai/pen/MWLJaPB?editors=1011)|
|Rochel|[Codepen](https://codepen.io/rochelwang1205/pen/NWodyOP?editors=1111)|
|yaoling.liang|[Codepen](https://codepen.io/Yao-Ling-L-/pen/gOqgJbz?editors=0011)|
|shcopy|[Codepen](https://codepen.io/shcopy/pen/XWOMwBK)|
|_shun0130|[Codepen](https://codepen.io/koba60052ww/pen/vYbgMKK?editors=0010)|
|Daylily|[Codepen](https://codepen.io/daylily/pen/YzBVwPK)|
| shawey.1a2b | [Codepen](https://codepen.io/Shawey/pen/LYqOxqW) |
| Hank._.z | [Codepen](https://codepen.io/linoiaby-the-sans/pen/rNPYzdy?editors=1111) |
|ChrisSQR|[Codepen](https://codepen.io/ChrisSQR/pen/yLZPomM)|
|nikkita_3544|[Codepen](https://codepen.io/vanessa7259/pen/bGzaJem?editors=0010)|
|Iris|[Codepen](https://codepen.io/iris831206/pen/KKJQWZL?editors=1011)|
|angela9741|[Codepen](https://codepen.io/coding-angela25/pen/KKJBzbL?editors=0010)
|macihuang|[Codepen](https://codepen.io/macy1215/pen/gOqjRmZ)
|sunny_08149|[Codepen](https://codepen.io/vjgpcfpk-the-builder/pen/KKJBbWm)
|bf_tsai|[Codepen](https://codepen.io/BF-Tsai/pen/zYeJxYP?editors=1111)
|NathanJames|[Codepen](https://codepen.io/ufo060204/pen/bGzxPyP)|
|skypassion5000|[Codepen](https://codepen.io/skypassion5000/pen/NWoOYBo?editors=0011)|
| 辣椒 | [Codepen](https://codepen.io/chilichen118/pen/wvNQdwK) |