---
# System prepended metadata

title: "\U0001F3C5 Day 15 - 陣列物件整合操作應用"
tags: [JS 直播班 - 2024 秋季班]

---

# 🏅 Day 15 - 陣列物件整合操作應用

### 題目

請依照下方程式碼中註解的要求完成這段程式碼（補上 `...` 的部分）：

```javascript=
let productInfo = {
  price: 1000,  // 購買價格
  coupons: [
    {
      due_date: "2022-10-15",  // 到期日
      id: 123,  
      is_enabled: 0,           // 是否啟用
      percent: 0.7,            // 折扣比例
      title: "特惠七折",        // coupon 標題
    },
    {
      due_date: "2022-08-08",  // 到期日
      id: 456,
      is_enabled: 1,           // 是否啟用
      percent: 0.5,            // 折扣比例
      title: "特惠五折",        // coupon 標題
    }
  ]
};

/* 請取得 coupons 陣列中 id 為 456 的 percent，並賦值給 discountPercent */
let discountPercent = ...;

/* 請取得 coupons 陣列中 id 為 456 的 title，並賦值給 title */
let title = ...;

/* 請修改 coupons 陣列中 id 為 456 的 到期日，將其延後兩日（至 2022-08-10）*/
...

/* 請取得 coupons 陣列中 id 為 456 的 is_enabled，並填入以下 if 判斷式中; 
如果判斷為 true，則對「購買價格」進行折扣 */
if(...) {
  /* 程式碼撰寫處，對「購買價格」進行折扣 */
  ...
  console.log(`優惠券「${title}」已啟用`);
} else {
  console.log("優惠券未啟用");
}
console.log(`購買價格 ${productInfo.price}`);
```



## 回報流程

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

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

<!-- 解答：  

let productInfo = {
  price: 1000,  // 購買價格
  coupons: [
    {
      due_date: "2022-10-15",  // 到期日
      id: 123,  
      is_enabled: 0,           // 是否啟用
      percent: 0.7,            // 折扣比例
      title: "特惠七折",        // coupon 標題
    },
    {
      due_date: "2022-08-08",  // 到期日
      id: 456,
      is_enabled: 1,           // 是否啟用
      percent: 0.5,            // 折扣比例
      title: "特惠五折",        // coupon 標題
    }
  ]
};
let discountPercent = productInfo.coupons[1].percent;
let title = productInfo.coupons[1].title;
productInfo.coupons[1].due_date = "2022-08-10";
if(productInfo.coupons[1].is_enabled) {
  /* 程式碼撰寫處，對「購買價格」進行折扣*/
  productInfo.price *= discountPercent;
  console.log(`優惠券「${title}」已啟用`);
} else {
  console.log("優惠券未啟用");
}
console.log(`購買價格 ${productInfo.price}`);

-->




回報區
---
| #   | Discord | CodePen / 答案 |
| --- | ----- | ----- |
| 01  | voke  | [CodePen](https://codepen.io/FiSi-the-lessful/pen/gOVLNbJ) | 
| 02  | Jainee  | [CodePen](https://codepen.io/Jainee0110/pen/abeWvLw) | 
| 03  | 泊岸  | [CodePen](https://codepen.io/qoq77416416/pen/oNKWxEz?editors=0012) | 
| 04  | haojing  | [CodePen](https://codepen.io/hjxu/pen/ZEgKvRx) | 
|05|Hailey|[CodePen](https://codepen.io/sxbokfja-the-flexboxer/pen/KKOqNao?editors=1012)|
|  06  | chris      | [CodePen](https://codepen.io/chris-chen-the-selector/pen/gOVRLWg?editors=0012) | 
|  07  | 毛巾 | [CodePen](https://codepen.io/bqdcjboa-the-solid/pen/JjgJbyP) | 
|  08  | tim | [CodePen](https://codepen.io/jskrtivy-the-animator/pen/ExqXNQB?editors=0011) |
|  09  | 倫倫 | [CodePen](https://codepen.io/f5badapple/pen/YzmQNWx?editors=0011) |
|  10 |  雪粒     | [CodePen](https://codepen.io/bzykdfhw-the-bashful/pen/oNKwBWw) |
|  11 |Lotte| [CodePen](https://codepen.io/hmkdoxuj-the-decoder/pen/LYwLbwR?editors=0011) |
|  12 |kaka_945| [CodePen](https://codepen.io/kay945/pen/qBejRxj) |
| 13 | 陳睿睿 | [CodePen](https://codepen.io/uwmrsusb-the-solid/pen/poMweZw?editors=0011) |
| 14 | Ruby | [CodePen](https://codepen.io/xivgaijl-the-selector/pen/zYgzZMa) |
| 15 | yuyuhunter_0509 | [CodePen](https://codepen.io/KRcube/pen/VwoWpdN?editors=0011) | 
| 16 | Lobinda | [CodePen](https://codepen.io/Lobinda/pen/JjgJNKq)|
| 17 | Kaya | [CodePen](https://codepen.io/kayaribi/pen/xxvrddo)|
|  18   |    Ariel   | [CodePen](https://codepen.io/ariel0510/pen/VwoWWZp?editors=0011) |
|  19   |    嚼勁先生   | [CodePen](https://codepen.io/James520284/pen/YzmQVdp) |
|20|mercury2508.| [CodePen](https://codepen.io/Mercury2508/pen/oNKwwJp) |
| 21 | Dolce_墨 | [CodePen](https://codepen.io/DolceTseng1026/pen/zYgzdKE) |
|  22   |   610    | [CodePen](https://codepen.io/YI-LING-LIU/pen/yLmXoMg) | 
|  23   |   Jrz    | [CodePen](https://codepen.io/JRZHENG/pen/VwoWMoP?editors=1111) | 
|  24   |a1phaki(小k)|[CodePen](https://codepen.io/a1phaki/pen/eYqRVOr?editors=1011)
|  25   |Mike|[CodePen](https://codepen.io/mike2049/pen/QWegQyq?editors=0012)
| 26 | Mos | [CodePen](https://codepen.io/mos25399/pen/ZEgyram?editors=0010) | 
| 27 | david1819 | [CodePen](https://codepen.io/David-Lin-the-vuer/pen/VwoWQda) | 
|  28   |   alec1203    | [CodePen](https://codepen.io/soloayaya/pen/PoMjjML?editors=1112) | 
|  29   | yuling      | [CodePen](https://codepen.io/yu-ling-peng/pen/QWegmeW?editors=0011) | 
|  30   | ycl325.etheddie | [CodePen](https://codepen.io/wdvikfuz-the-selector/pen/rNXwvmz) | 
|   31  |   Celine    | [CodePen](https://codepen.io/szuning/pen/QWegOoL?editors=0010) | 
| 32    |   JIA    | [CodePen](https://codepen.io/nzaicwlw-the-styleful/pen/poMwVGr?editors=0011) | 
| 33 |ABOOS| [CodePen](https://codepen.io/guhungyin/pen/vYoZMOz?editors=0012) | 
| 34 | GTR150 | [CodePen](https://codepen.io/Wer-Qwe/pen/MWNoNdE?editors=1112) | 
| 35 | .tsz_ying   | [CodePen](https://codepen.io/bekgnohe-the-selector/pen/PoMjEOY?editors=0011) | 
| 36 | yuyeh_1212 | [CodePen](https://codepen.io/yuyeh1212/pen/xxvLxjR) |
| 37 | Sonia | [CodePen](https://codepen.io/YUJOU/pen/ZEgJEeg?editors=0011) |
| 38 | ab567ab5 | [CodePen](https://codepen.io/WanTzu-Chiang/pen/rNXzLdV?editors=0011) |
| 39 | ABow_Chen | [CodePen](https://codepen.io/fred39392001/pen/bGXrYPZ) |
|  40   |   蘑菇星星    | [CodePen](https://codepen.io/brrrieon-the-vuer/pen/yLmopjV?editors=0012) | 
|41|邵|[Codepen](https://codepen.io/ukscrlno-the-typescripter/pen/JjgJEdK)|
|42|是在哈囉|[Codepen](https://codepen.io/miyxdhem-the-solid/pen/rNXzqMv?editors=1111)|
|43|Seris|[Codepen](https://codepen.io/Dale-Chien/pen/yLmowLR)|
|44|jerry_66983| [CodePen](https://codepen.io/Barry-C/pen/mdNBbYr?editors=0012) | 
|45|jimmy.0706|[Codepen](https://codepen.io/JimmyMao/pen/oNKGLrW?editors=0012)|
|46|Rogan|[Codepen](https://codepen.io/RoganHsu/pen/abewoYo?editors=1112)|
| 47  | Ed Huang  | [CodePen](https://codepen.io/yide1986/pen/MWNEpxJ) | 
| 48 | Jim | [CodePen](https://codepen.io/JimChou/pen/WNVZjmZ?editors=0011) | 
|  49   |   Emma    | [CodePen](https://codepen.io/Emma0919/pen/YzmrYav) | 
|  50   |   Ana    | [CodePen](https://codepen.io/Ana-Wu/pen/xxvXjJX?editors=0011) | 
|  51   |    KUN.   | [CodePen](https://codepen.io/barry91205/pen/BaXwGbx?editors=1111) |
|  52   | yaoling.liang | [CodePen](https://codepen.io/Yao-Ling-L-/pen/jOgGjEY?editors=1011) |
|53 | 陳小廷 | [CodePen](https://codepen.io/ting1124/pen/mdNqOmY) | 
|54 | xiang5141 | [CodePen](https://codepen.io/XIANG-XIANG/pen/OJKOWBO?editors=0010) | 
|5 | yu | [CodePen](https://codepen.io/yu_ch12/pen/XWvzgVQ) | 
|56 | Joannehu | [CodePen](https://codepen.io/nelbabkv-the-flexboxer/pen/xxvPPro?editors=0011) | 
|57 | joylu0902 | [CodePen](https://codepen.io/joylu0902/pen/qBeVxGg) | 
| 58 | Glen_69515 | [CodePen](https://codepen.io/glenyaochih/pen/rNXJwGv?editors=1111) | 
|59|朋仔|[CodePen](https://codepen.io/YPHUANG/pen/KKOQQOM?editors=0012)|
|60|GAVI|[CodePen](https://codepen.io/qbafldcv-the-scripter/pen/poMWzBV)|
|61|Tatsu|[CodePen](https://codepen.io/chindesu0207/pen/OJKZgXG)|
|62|Yen| [CodePen](https://codepen.io/yuxxxlouyen/pen/ExqLowG?editors=0011) | 
|63|野鴿| [CodePen](https://codepen.io/HoshinoSyouta/pen/vYojdKx?editors=0012) | 
|64|Hedwig| [CodePen](https://codepen.io/adirehfz-the-encoder/pen/eYqKOWa?editors=1012) | 
|65|charlottelee| [CodePen](https://codepen.io/char849/pen/wvVXpXo) |
|66|維妮|[CodePen](https://codepen.io/Maggy-Lin/pen/WNVgPro?editors=0011) |
|67|iamcan|[CodePen](https://codepen.io/uhnxswdq-the-typescripter/pen/wvVEZba) |
|68|zobody|[CodePen](https://codepen.io/Zoe-Shih/pen/jOgvgEg) |
|69|KOMATSU PEI|[CodePen](https://codepen.io/Komatsu2021/pen/JjgeYPV?editors=0012) |
|70|Nocab Wang ( 培根 )|[CodePen](https://codepen.io/PeihanWang/pen/QWezQJE?editors=0011) |
|71|Amy(咂摳)| [CodePen](https://codepen.io/nnxucgmc-the-builder/pen/PoMLKNb?editors=0011) | 
|72|Satar| [CodePen](https://codepen.io/SatarKuo/pen/OPLWvWp?editors=0011) | 
|73|ji3di|[Codepen](https://codepen.io/jwuuhtxh-the-builder/pen/YPKVMLN?editors=0011)
|74|Chuang|[CodePen](https://codepen.io/uidoytjq-the-solid/pen/qEWxpXV?editors=0011)


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