owned this note
owned this note
Published
Linked with GitHub
---
tags: 30 天軟體工程師體驗營|2025
---
# 🏅 JS 任務 Day9 - 陣列設計
> 建議觀看的影音章節:
> JS - 陣列教學
>
### 題目一:陣列長度計算
``` =JavaScript
// input 輸入
checkLength([1,2,3])
checkLength([5,8,39,1,2,3])
checkLength([])
// output 輸出
3
6
0
```
### 題目二:增減陣列內容
* 請透過 aryControl 函式,來增減 `ary` 陣列內容。
``` =JavaScript
const ary = [];
// input 輸入
aryControl("增加","black")
aryControl("增加","red")
aryControl("增加","white")
aryControl("增加","blue")
aryControl("刪除指定筆數",3)
aryControl("刪除指定筆數",1)
// output 輸出
["black"]
["red","black"]
["white","red","black"]
["blue","white","red","black"]
["blue","white","black"]
["white","black"]
```
### 題目三:for+陣列相加產生器,邏輯思考題
* 請嘗試用 `numAry` 變數,並搭配 `addAry` 函式來解此題目
``` =JavaScript
const numAry = [1,2,3,4,5]
// input 輸入
addAry(1);
addAry(2);
addAry(3);
addAry(4);
addAry(5);
// output 輸出
1
3
6
10
15
```
## 回報流程
1. 將答案貼在 Codepen 並複製 Codepen 連結貼至「回報區」回報
(也可以將答案直接貼至「回報區」)

回報區
---
| 報數 | Discord 名字 | Codepen/其他回饋 |
|:----:|:--------------------:|:----------------------------------------------------------------------------:|
|1|7Lun| [Day9-Codepen](http://codepen.io/mfyvqhsn-the-bold/pen/EaapgdG) |
| 2 | 4chan | [Codepen](https://codepen.io/ijuolaqc-the-looper/pen/xbbJgLL?editors=1011) |
|3|小趴|[Codepen](https://codepen.io/papa2415/pen/dyEbbPg)|
| 4 | ying | [Codepen](https://codepen.io/Lara-Lin/pen/MYYBJXj?editors=1112) |
| 5 | 馬德| [Codepen](https://codepen.io/maywang/pen/jEEpBea?editors=0012) |
| 6 | dean | [Codepen](https://codepen.io/ch933114/pen/ByyPWpj?editors=0011) |
| 7 | SeanLuTW | [Codepen](https://codepen.io/sean85914/pen/emmjvbL) |
| 8 | Joseph_Kyuu | [Codepen](https://codepen.io/zrzfastd-the-reactor/pen/LEEByEY) |
| 9 | 蛋白 | [蛋白的JS Codepen Day 9](https://codepen.io/sjlu-0/pen/vEEaxmo) |
| 10 | 登登登 | [Codepen](https://codepen.io/Duncanin/pen/NPPBjeO) |
| 11 | RUDY | [Codepen](https://codepen.io/Rudy-crw/pen/EaapXbm?editors=0010) |
| 12 | B | [Codepen](https://codepen.io/Babel777/pen/emmjWmb) |
| 13 | 叮咚 | [Codepen](https://codepen.io/pinchieh-lin/pen/bNNjrMg) |
| 14 | postar| [Codepen](https://codepen.io/peter_hung/pen/GggBmxM)|
| 15 | 力文| [Codepen](https://codepen.io/liwenchiou/pen/yyyqvNq?editors=0011)|
| 16 | WEIWEI | [Codepen](https://codepen.io/weiwei93/pen/bNNjWwa) |
| 17 | WAWATA | [Codepen](https://codepen.io/wa-wa-GNOHC-WA-Wa/pen/PwwBgeP)
| 18 | 林明德 |[Codepen](https://codepen.io/lwescocn-the-vuer/pen/VYYGwbr?editors=1111)
| 19 | ann.328 |[Codepen](https://codepen.io/yqmegupa-the-styleful/pen/dPPqPNw)
| 20 | Leonard |[Codepen](https://codepen.io/hyyfjqra-the-sans/pen/MYYqyMd)
| 21 | nora_zizi | [Codepen](https://codepen.io/Nora-Ch/pen/pvvOEaP?editors=1111) |
| 22 | William Hsieh | [Codepen](https://codepen.io/lsaimqxa-the-vuer/pen/KwwxMWj?editors=0012) |
| 23 | Hugh | [Codepen](https://codepen.io/Hugh-Chen/pen/MYYqjZr?editors=0011) |
| 24 | ArvinSu | [Codepen](https://codepen.io/Arvin-Su/pen/qEEMRMP) |
| 25 | yang |[codepen](https://codepen.io/Yang-J/pen/KwwxmMQ?editors=0012)|
|26|Saika|[Codepen](https://codepen.io/saika4501/pen/oggPYPx?editors=0111)|
| 27 | mercury2508. | [Codepen](https://codepen.io/Mercury2508/pen/ZYYMoYB) |
| 28 | QoQ |[codepen](https://codepen.io/xxmevbri-the-reactor/pen/vEEzRYZ)|
| 29 | 牛奶 |[codepen](https://codepen.io/0omilko0/pen/yyyxZvq?editors=0011)|
| 30 | Archang |[codepen](https://codepen.io/pxfnrvgk-the-styleful/pen/azzjYvm)|
|31|蛋殼|[Codepen](https://codepen.io/weybrian/pen/LEEgZPG)
| 32 | Jessie | [Jessie 的 Codepen](https://codepen.io/bakyfkso-the-looper/pen/azzRvxJ)
| 33 | Jingle0900 | [Codepen](https://codepen.io/EvaLi0472/pen/EaadQwG?editors=1010)
| 34 | Chuang | [Codepen](https://codepen.io/uidoytjq-the-solid/pen/wBBYmgj?editors=0011) |
| 35 | CBK | [Codepen](https://codepen.io/BK-C-the-styleful/pen/bNNmMaG) |
| 36 | Kath | [Codepen](https://codepen.io/JLin-the-lessful/pen/qEEJyPN) |
| 37 | Ariel | [Codepen](https://codepen.io/ariel0510/pen/QwwJwgW?editors=0011) |
| 38 | BL | [Codepen](https://codepen.io/bonnieli1414/pen/GggwrdO?editors=0012) |
| 39 | Sonia | [Codepen](https://codepen.io/YUJOU/pen/MYYzovL?editors=0011) |
| 40 | oyll | [Codepen](https://codepen.io/dizzydog-rgb/pen/GggwypG?editors=0011) |
| 41 | wei_0982 | [Codepen](https://codepen.io/nico-lai/pen/gbbdovY) |
| 42 | tung | [Codepen](https://codepen.io/oltsegon-the-looper/pen/PwwxzYp) |
| 43 | 姜承 | [Codepen](https://codepen.io/Troy0718/pen/bGmvoeQ?editors=0012) |
| 44 | Rogan | [Codepen](https://codepen.io/RoganHsu/pen/RNNvxqQ?editors=1111) |
|45|JHT|[Codepen](https://codepen.io/juanht/pen/LEEqZmY?editors=0012)|
| 46 | Toung | [Codepen](https://codepen.io/Toung/pen/azzxJYo)
| 47 | Apple Pie | [Codepen](https://codepen.io/ymevqzjf-the-builder/pen/dPPLdam)
| 48 | kelsonhouse | [Codepen](https://codepen.io/Kelson-House/pen/dPPLqWP?editors=0011) |
| 49 | Anna | [Codepen](https://codepen.io/Anna-Teng/pen/KwwYLjw?editors=1111)|
| 50 | allen3290 | [Codepen](https://codepen.io/udadkudw-the-looper/pen/LEEoyry?editors=1111)|
| 51 | duchi | [Codepen](https://codepen.io/sqaz0502/pen/EaazzdK)|
| 52 | vima | [Codepen](https://codepen.io/chin7004/pen/RNNzZYP?editors=0011) |
| 53 | ja4071 | [Codepen](https://codepen.io/SHAO-L/pen/QwwRyPx?editors=1112) |
| 53 | ninii | [Codepen](https://codepen.io/niiniiii/pen/GggVgOR?editors=1111) |
| 54 | Yi-Kuei | [Codepen](https://codepen.io/Yi-Kuei-Chuang/pen/LEVEENy?editors=1111) |
| 55 | xiaocai_97765 | [Codepen](https://codepen.io/dupre55667788/pen/azOzBpY?editors=0010)
| 56 | 610 | [Codepen](https://codepen.io/YI-LING-LIU/pen/PwqNzWv) |
| 57 | taishan_90178| [Codepen](https://codepen.io/candy99/pen/RNPLwqX?editors=0012)
| 58 | kent_31665 | [Codepen](https://codepen.io/kentlee406/pen/ByNGoYX?editors=0011)
| 59 | haohaoliao | [Codepen](https://codepen.io/yuyuyuhaohao/pen/ogbLxbO) |
<!-- | num | user | [Codepen]() | -->
<!-- -- > -->
<!-- 解答:
題目一:
function checkLength(arr) {
return arr.length;
}
題目二:
const ary = [];
function aryControl(action, value) {
if (action === "增加") {
ary.unshift(value); // 從前面加入
} else if (action === "刪除指定筆數") {
ary.splice(0, value); // 從前面開始刪除指定筆數
}
console.log([...ary]); // 輸出目前陣列內容
}
題目三:
const numAry = [1, 2, 3, 4, 5];
let total = 0;
function addAry(index) {
total += numAry[index - 1]; // index 為 1~5,所以減 1
console.log(total);
}