---
# System prepended metadata

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

---

# 🏅 Day 16 - 函式觀念一

依照下方教學練習，並回答問題。

### 基本函式寫法教學 

可參考課程影音「函式 function - 函式寫法教學」章節

1. 宣告、命名函式
```javascript=
// 在此 morningAction 是自定義的名稱
function morningAction() {
  // 定義函式執行內容
  console.log("刷牙");
  console.log("洗臉");
} 
```
2. 呼叫函式
```javascript=
morningAction();
morningAction();
```
> 1. 函式撰寫完後，需要呼叫才會執行
> 2. 函式可以重複呼叫

問題
---
1. 宣告一個函式，讓此函式執行後會印出字串 `"這是一個函式"`
2. 觀看下方程式碼，最後會印出什麼
```javascript=
function sayHello() {
  console.log("ㄋ好");
}
console.log("Bye！");
```
3. 觀看下方程式碼，選出正確敘述
```javascript=
function sayHi() {
  console.log("Hi");
}
sayHi();
sayHi();

/* 選項 
   1. 函式不能重複呼叫，會報錯
   2. 最後會印出兩個 Hi
   3. 只會執行一次，印出一個 Hi
*/
```

## 回報流程

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

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

<!-- 解答：  

1. 函式名稱可以隨意命名，盡量與執行內容相符即可
```
function printString() {
  console.log("這是一個函式");
}
printString();  // 記得呼叫才會執行
```

2. Bye！
3. 選項 2
-->




回報區
---
| #   | Discord | CodePen / 答案 |
| --- | ----- | ----- |
| 01 | 泊岸 | [CodePen](https://codepen.io/qoq77416416/pen/bGXWpxx?editors=0012) |
|02|voke|[CodePen](https://codepen.io/FiSi-the-lessful/pen/mdNWyOe)|
| 03 | 毛巾 |[CodePen](https://codepen.io/bqdcjboa-the-solid/pen/BaXdwXw)|
| 04 | tim |[CodePen](https://codepen.io/jskrtivy-the-animator/pen/oNKeoGB?editors=0011)|
| 05 | Lobinda | [CodePen](https://codepen.io/Lobinda/pen/XWvaVQV)
| 06 | Ruby | [CodePen](https://codepen.io/xivgaijl-the-selector/pen/QWeMQNp) |
| 07 | ABow_Chen | [CodePen](https://codepen.io/fred39392001/pen/dyxzdXE) |
|08|陳睿睿|[CodePen](https://codepen.io/uwmrsusb-the-solid/pen/VwozXmm?editors=1111)|
|09|Jainee|[CodePen](https://codepen.io/Jainee0110/pen/wvVqmjE)|
|10|Lotte|[CodePen](https://codepen.io/hmkdoxuj-the-decoder/pen/BaXdrVP?editors=0011)|
|11|haojing|[CodePen](https://codepen.io/hjxu/pen/JjgyLBb)|
|12|david1819|[CodePen](https://codepen.io/David-Lin-the-vuer/pen/GRVvdZY)|
| 13 | Dolce_墨 |[CodePen](https://codepen.io/DolceTseng1026/pen/PoMKeOv)|
| 14 | GTR150 | [CodePen](https://codepen.io/Wer-Qwe/pen/WNVEyqM?editors=1112) | 
| 15 | Kaya | [CodePen](https://codepen.io/kayaribi/pen/xxvLJEG?editors=0011) | 
| 16 | ycl325.etheddie | [CodePen](https://codepen.io/wdvikfuz-the-selector/pen/mdNMjOw) | 
|17|mercury2508.| [CodePen](https://codepen.io/Mercury2508/pen/qBeXyej) |
|  18   |   Ariel    | [CodePen](https://codepen.io/ariel0510/pen/rNXzZVL?editors=0011) |
| 19 | yuyuhunter_0509 | [CodePen](https://codepen.io/KRcube/pen/ZEgJqEX?editors=0011) | 
| 20 | 是在哈囉 | [CodePen](https://codepen.io/miyxdhem-the-solid/pen/qBeXJQe) | 
|21|brucelee0629| [CodePen](https://codepen.io/xxhdklwi-the-decoder/pen/BaXdqgd?editors=0011) | 
| 22 | Mos | [CodePen](https://codepen.io/mos25399/pen/XWvaymw?editors=0010) |
| 23 | jimmy.0706 | [CodePen](https://codepen.io/JimmyMao/pen/jOgLQVe?editors=0012) |
| 24 | Sonia | [CodePen](https://codepen.io/YUJOU/pen/GRVvwrv?editors=0011) |
|25|邵|[CodePen](https://codepen.io/ukscrlno-the-typescripter/pen/NWQvexV?editors=1111)|
|  26   |   JIA    | [CodePen](https://codepen.io/nzaicwlw-the-styleful/pen/YzmxdQj?editors=0010) | 
| 27 | yuyeh_1212 | [CodePen](https://codepen.io/yuyeh1212/pen/WNVELyv) |
| 28 | JRz | [CodePen](https://codepen.io/JRZHENG/pen/poMrYEQ) |
|29|jerry_66983| [CodePen](https://codepen.io/Barry-C/pen/PoMJoNK?editors=0011) |
|30|Hailey|[Codepen](https://codepen.io/sxbokfja-the-flexboxer/pen/MWNEWVd?editors=0011)|
|31|kaka_945|[Codepen](https://codepen.io/kay945/pen/poMWjmX)|
|32|Celine|[Codepen](https://codepen.io/szuning/pen/dyxzqjq)|
|33|yuling|[Codepen](https://codepen.io/yu-ling-peng/pen/dyxVOMa?editors=0011)|
|34|Rogan|[Codepen](https://codepen.io/RoganHsu/pen/bGXoBYB)|
|35|.tsz_ying|[Codepen](https://codepen.io/bekgnohe-the-selector/pen/VwoMPPj?editors=0011)|
|36|嚼勁先生|[Codepen](https://codepen.io/James520284/pen/ZEgXLZz)|
| 37 | Ana | [Codepen](https://codepen.io/Ana-Wu/pen/xxvXjaX?editors=0011)|
| 38 | KUN.|[Codepen](https://codepen.io/barry91205/pen/dyxVwEj?editors=1111)|
| 39 | yaoling.liang |[Codepen](https://codepen.io/Yao-Ling-L-/pen/ExqwByJ?editors=1011)|
|  40   |   Emma    | [CodePen](https://codepen.io/Emma0919/pen/gOVXamg) | 
|  41   | ab567ab5 | [CodePen](https://codepen.io/WanTzu-Chiang/pen/JjgOKyP?editors=0011) |
|42|陳小廷|[CodePen](https://codepen.io/ting1124/pen/XWvzNqE)|
|43|yu|[CodePen](https://codepen.io/yu_ch12/pen/gOVXRdR)|
|  44   |   610    | [CodePen](https://codepen.io/YI-LING-LIU/pen/zYgPEgJ) | 
|45|Joannehu|[CodePen](https://codepen.io/nelbabkv-the-flexboxer/pen/zYgPPLV?editors=0011)|
|46|joylu0902|[CodePen](https://codepen.io/joylu0902/pen/eYqeMOr)|
|47|a1phaki(小k)|[CodePen](https://codepen.io/a1phaki/pen/yLmPRNO?editors=0010)|
|48|alec1203|[CodePen](https://codepen.io/soloayaya/pen/yLmPWVa?editors=1012)|
|49|ABOOS| [CodePen](https://codepen.io/guhungyin/pen/bGXawOz?editors=0012) | 
|  50   |   chris   | [CodePen](https://codepen.io/chris-chen-the-selector/pen/RwXxKLW?editors=0010) | 
|51|Seris|[CodePen](https://codepen.io/Dale-Chien/pen/NWQXVmx)|
|52|Jim|[CodePen](https://codepen.io/JimChou/pen/ZEgvdzJ?editors=0011)|
| 53 | Glen_69515 | [CodePen](https://codepen.io/glenyaochih/pen/mdNXXBG?editors=1111) | 
| 54 | GAVI | [CodePen](https://codepen.io/qbafldcv-the-scripter/pen/BaXwBER?editors=0011) | 
|55|Tatsu| [CodePen](https://codepen.io/chindesu0207/pen/OJKZgbG) | 
|56| Yen | [CodePen](https://codepen.io/yuxxxlouyen/pen/RwXyxBa?editors=0011) | 
|57|Hedwig| [CodePen](https://codepen.io/adirehfz-the-encoder/pen/xxvzKjV?editors=1111) | 
|58|野鴿| [CodePen](https://codepen.io/HoshinoSyouta/pen/dyxKWKN?editors=0010) |
|59|Ed Huang| [CodePen](https://codepen.io/yide1986/pen/oNKMbvy) | 
|60|蘑菇星星| [CodePen](https://codepen.io/brrrieon-the-vuer/pen/yLmqgxY?editors=1012) | 
|61|charlottelee| [CodePen](https://codepen.io/char849/pen/zYgLPGG) | 
|62|zobody| [CodePen](https://codepen.io/Zoe-Shih/pen/ExqeqZm) | 
|63|iamcan| [CodePen](https://codepen.io/uhnxswdq-the-typescripter/pen/VwoEyqG) | 
|64|維妮| [CodePen](https://codepen.io/Maggy-Lin/pen/NWQEKmj?editors=0011) | 
|65|KOMATSU PEI| [CodePen](https://codepen.io/Komatsu2021/pen/zYgMrZB?editors=0012) | 
|66|Nocab| [CodePen](https://codepen.io/PeihanWang/pen/rNXPJqy?editors=1011) | 
|67|Amy(咂摳)| [CodePen](https://codepen.io/nnxucgmc-the-builder/pen/rNXRzdb?editors=0011) | 
|68|Satar| [CodePen](https://codepen.io/SatarKuo/pen/PwYmoOz?editors=0011) | 
|69|Chuang|[CodePen](https://codepen.io/uidoytjq-the-solid/pen/XJrExzV?editors=0010)

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