owned this note
owned this note
Published
Linked with GitHub
---
tags: 30 天軟體工程師體驗營|2025
---
> JS - 陣列教學
> JS - 物件教學
> JS - 陣列與物件整合運用
# 🏅 JS 任務 Day16 - 陣列操作
### 題目一:陣列索引
* 陣列索引,點出是第幾筆資料
``` =JavaScript
const numAry = [1,3,4,6,8];
// input 輸入
checkNum(3)
checkNum(9)
checkNum(83)
checkNum(6)
// output
位置在第2筆
false
false
位置在第4筆
```
### 題目二:陣列相乘
* 將陣列裡面的各個陣列數字相乘
``` =JavaScript
const doubleAry = [
[1,2,3],
[3,5,6],
[2,2,2,2],
];
// input 輸入
callAry(doubleAry)
// output
"第1個陣列相乘是6,第2個陣列相乘是90,第三個陣列相乘是16"
```
### 題目三:陣列排序
* 正序、反序設計
``` =JavaScript
const a = [1,3,4,6,8];
const b = [3,6,12];
// input 輸入
sortAry("從小到大",[8,3,1,7])
sortAry("從小到大",[99,22,11,33])
sortAry("從大到小",[7,2,33,4])
// output
[1,3,7,8]
[11,22,33,99]
[33,7,4,2]
```
## 回報流程
1. 將答案貼在 CodePen 並複製 CodePen 連結貼至「回報區」回報
(也可以將答案直接貼至「回報區」)

<!--解答:
題目一:
const numAry = [1, 3, 4, 6, 8];
function checkNum(n) {
const index = numAry.indexOf(n);
if (index === -1) {
console.log(false);
} else {
console.log(`位置在第${index + 1}筆`);
}
}
題目二:
function callAry(arr) {
const result = arr.map((subArr, idx) => {
const product = subArr.reduce((acc, cur) => acc * cur, 1);
return `第${idx + 1}個陣列相乘是${product}`;
});
console.log(result.join(','));
}
題目三:
function sortAry(order, arr) {
let result = [...arr];
if (order === "從小到大") {
result.sort((a, b) => a - b);
} else if (order === "從大到小") {
result.sort((a, b) => b - a);
}
console.log(result);
}
-->
回報區
---
| 報數 | Discord 名字 | CodePen/其他回饋 |
|:----:|:--------------------:|:----------------------------------------------------------------------------:|
| 1 | 4chan | [CodePen](https://codepen.io/ijuolaqc-the-looper/pen/ZYYZVNZ?editors=1011) |
| 2 | dean | [CodePen](https://codepen.io/ch933114/pen/ByyEMZO?editors=0011) |
| 3 | 7Lun| [Day-16 CodePen](https://codepen.io/mfyvqhsn-the-bold/pen/QwwPopy?editors=0011) |
| 4 | ying | [CodePen](https://codepen.io/Lara-Lin/pen/EaaJrXK) |
| 5 | B | [CodePen](https://codepen.io/Babel777/pen/wBBZOow) |
|6|Saika|[Codepen](https://codepen.io/saika4501/pen/KwwYJjp?editors=0011)|
| 7 |登登登|[Codepen](https://codepen.io/Duncanin/pen/zxxXXRX)|
|8|小趴|[Codepen](https://codepen.io/papa2415/pen/KKLdGzr)|
| 9 | pastor | [CodePen](https://codepen.io/peter_hung/pen/jEERJwr) |
| 10 | han | [CodePen](https://codepen.io/iamHanCheng/pen/wBBZOxM?editors=0011) |
| 11 | 馬德 | [CodePen](https://codepen.io/maywang/pen/NPPmVZQ?editors=0012) |
| 12 | RUDY | [CodePen](https://codepen.io/Rudy-crw/pen/YPPbzOM?editors=0011) |
| 13 | WEIWEI | [CodePen](https://codepen.io/weiwei93/pen/VYYRXbN) |
| 13 | WAWATA | [CodePen](https://codepen.io/wa-wa-GNOHC-WA-Wa/pen/emmaZpw) |
|14|蛋殼|[Codepen](https://codepen.io/weybrian/pen/raagLbJ)
| 15 | nora_zizi | [CodePen](https://codepen.io/Nora-Ch/pen/PwwvGMJ?editors=1111) |
| 16 | 牛奶 | [CodePen](https://codepen.io/0omilko0/pen/JooqXQy?editors=0011) |
| 17 | mercury2508. | [CodePen](https://codepen.io/Mercury2508/pen/MYYdJJj) |
| 18 | HawkeyeLin | [CodePen](https://codepen.io/long-long/pen/OPPYWwJ) |
| 19 | Ariel | [CodePen](https://codepen.io/ariel0510/pen/xbbNdOw?editors=0011) |
| 20 | William Hsieh | [CodePen](https://codepen.io/lsaimqxa-the-vuer/pen/vEEwmRW?editors=0012) |
| 21 | yang |[codepen](https://codepen.io/Yang-J/pen/gbbJWQj?editors=0012)|
| 22 | Leonard |[codepen](https://codepen.io/hyyfjqra-the-sans/pen/JooqOwB)|
| 23 | jingle0900 |[codepen](https://codepen.io/EvaLi0472/pen/zxxQrEe?editors=1010)|
| 24 | SeanLuTW | [Codepen](https://codepen.io/sean85914/pen/qEEGKOO)|
| 25 | 力文 | [Codepen](https://codepen.io/liwenchiou/pen/YPPbjyL?editors=0011)|
| 26 | Esther | [Codepen](https://codepen.io/biunpujm-the-flexboxer/pen/dPPEqrY?editors=1111)|
|27|JHT|[Codepen](https://codepen.io/juanht/pen/OPPYadJ?editors=0012)|
|28|kelsonhouse|[Codepen](https://codepen.io/Kelson-House/pen/KwwjgJQ?editors=0011)|
|29|BL|[Codepen](https://codepen.io/bonnieli1414/pen/PwwrGdG?editors=0012)|
| 30 | Chuang | [CodePen](https://codepen.io/uidoytjq-the-solid/pen/xbbodGv?editors=0012) |
| 31 | Hugh | [CodePen](https://codepen.io/Hugh-Chen/pen/Pwwrjeg?editors=1111) |
| 32 | wei_0982 | [CodePen](https://codepen.io/nico-lai/pen/OPPYNEo) |
| 33 | oyll | [CodePen](https://codepen.io/dizzydog-rgb/pen/WbvezKP?editors=0011) |
| 34 | ja4071 | [CodePen](https://codepen.io/SHAO-L/pen/vEOOPjN?editors=1112)
| 35 | Jessie_Yu | [Jessie_Yu 的 Codepen](https://codepen.io/bakyfkso-the-looper/pen/ByNjGEz)|
| 36 | vima | [CodePen](https://codepen.io/chin7004/pen/dPoMORW?editors=0011) |
| 37 | Yi-Kuei | [CodePen](https://codepen.io/Yi-Kuei-Chuang/pen/vEOGwre?editors=1112) |
| 38 | xiaocai_97765 | [Codepen](https://codepen.io/dupre55667788/pen/raVLYWL?editors=0010)
| 39 | ninii | [CodePen](https://codepen.io/niiniiii/pen/PwqmJpv?editors=1111) |
| 40 | taishan_90178 | [CodePen](https://codepen.io/candy99/pen/vEOeGeW?editors=0012) |
| 41 | ann.328 | [Codepen](https://codepen.io/yqmegupa-the-styleful/pen/KwpZwga) |
| 42 | 叮咚 | [Codepen](https://codepen.io/pinchieh-lin/pen/vEOVJNY) |
| 43 | Rogan | [Codepen](https://codepen.io/RoganHsu/pen/JodeoJz?editors=1112) |
<!--【快速複製】
| num | user | [CodePen]() |
-->