---
# System prepended metadata

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

---

---
tags: JS 直播班 - 2023 秋季班
---
# 🏅 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 / 答案 |
| :-----: | :-----------: |
| pinyi_9 | [CodePen](https://codepen.io/Wpypy/pen/oNmjdQK?editors=1010) |
| Zem | [CodePen](https://codepen.io/Potoro/pen/BaMoVjd) |
| 楓仔 | [CodePen](https://codepen.io/maplestartend/pen/BaMoVod?editors=0012) |
| yaoling.liang | [CodePen](https://codepen.io/Yao-Ling-L-/pen/poGjKJK?editors=0012) |
| 銀光菇 | [CodePen](https://codepen.io/genesynthesis/pen/LYqprYY) |
| Rxzan | [CodePen](https://codepen.io/Tzuru-Chen/pen/gOqaKbg) |
| ShangChu | [CodePen](https://codepen.io/shangchu0412/pen/PoVPaZm?editors=0012) |
| Ching | [CodePen](https://codepen.io/tzuchingg/pen/XWOmYJO) |
| cest_jessie | [CodePen](https://codepen.io/itsjessiechen/pen/rNPOKLR) |
| yuan! | [CodePen](https://codepen.io/townyuan/pen/dyaYKzX) |
| runweiting | [CodePen](https://codepen.io/weiting14/pen/PoVPaop) |
| CPing | [CodePen](https://codepen.io/CPing/pen/bGzVjGO) |
| Ivy | [CodePen](https://codepen.io/Irene-Ke/pen/QWYjBEX?editors=0010) |
| 蛋塔 | [CodePen](https://codepen.io/Hong-Game1/pen/KKJdBBd?editors=1111) |
| 風羽 | [CodePen]([連結](https://codepen.io/Joy-Huang/pen/yLZYqRJ?editors=0011)) |
| kuanju27 | [CodePen](https://codepen.io/Eero-Chiao/pen/GRzpBXz) |
| Helen | [CodePen](https://codepen.io/milkteamonster/pen/jOdbvqV?editors=0011) |
| Winnie | [CodePen](https://codepen.io/codepen-io-winnie/pen/QWYjBrw?editors=0011) |
| Alyce | [CodePen](https://codepen.io/alycehwy/pen/yLZYxoz?editors=0010) |
| Chia Pin | [CodePen](https://codepen.io/joker-cat/pen/BaMoOPL) |
| Uli | [CodePen](https://codepen.io/uli1313/pen/rNPOZrr?editors=0012) |
| claire | [CodePen](https://codepen.io/yi-wen-chen/pen/zYevJXy) |
| xin | [CodePen](https://codepen.io/Estherrrrrr999/pen/YzByJyw) |
| lychee_kk | [CodePen](https://codepen.io/kakakala/pen/XWOmxbO) |
| tanuki5863 | [CodePen](https://codepen.io/tanuki320/pen/NWoGOxX?editors=0011) |
| celinelinnn | [CodePen](https://codepen.io/celinephoebe/pen/NWoGOWa) |
| 依依 | [CodePen](https://codepen.io/pen/?editors=0011) |
| Andy | [CodePen](https://codepen.io/andy31342/pen/GRzpYpN?editors=0011) |
| Moreene | [CodePen](https://codepen.io/Moreene/pen/MWLaPVx) |
| yuan2781 | [CodePen](https://codepen.io/ismebir/pen/OJdyowX) |
| minnielin | [CodePen](https://codepen.io/ShengXin-Lin/pen/bGzVQbQ?editors=1010) |
| LinaChen | [CodePen](https://codepen.io/LinaChen/pen/vYbNVxy) |
| zona | [CodePen](https://codepen.io/w242920/pen/NWoGEaZ?editors=1111) |
| ming0712 | [CodePen](https://codepen.io/StevenHuang/pen/BaMovaa?editors=0010) |
| MDFK | [CodePen](https://codepen.io/maywang/pen/rNPOPBQ?editors=0012) |
| phyllis | [CodePen](https://codepen.io/Phyllis-Cheng/pen/jOdbdMx) |
| Ataraxia | [CodePen](https://codepen.io/ataraxia8888/pen/LYqYLKP) |
| 維哲 | [CodePen](https://codepen.io/kwz1202/pen/VwgvgOW) |
| kawa | [CodePen](https://codepen.io/z83xji6/pen/XWOmOvb?editors=0012) |
| dora | [CodePen](https://codepen.io/dorayu/pen/yLZYwxO?editors=0011) |
| 奔跑吧(GTR150)) | [CodePen](https://codepen.io/Wer-Qwe/pen/ExrVMGv?editors=1112) |
| santu0868 | [CodePen](https://codepen.io/HatsumiSan/pen/GRzpLxJ?editors=1010) |
| ⭐️小正 | [CodePen](https://codepen.io/colorgolden/pen/oNmjOoV) |
| 荷菓かのり | [CodePen](https://codepen.io/oogxwkvw-the-builder/pen/MWLaRLV?editors=0012) |
| shuuu shuuu | [CodePen](https://codepen.io/afjrvjzl-the-bashful/pen/mdveYer?editors=0011) |
| xiaokui_71292 | [CodePen](https://codepen.io/pen?template=LYqpoOG) |
| ann6212 | [CodePen](https://codepen.io/yqmegupa-the-styleful/pen/YzBybxG?editors=1012) |
| damon0323 | [CodePen](https://codepen.io/swk9eny2/pen/RwvWmyV?editors=0011) |
| hsuanlee1084 | [CodePen](https://codepen.io/hsuanlee1024/pen/OJdyePw?editors=0010) |
| 保羅 | [CodePen](https://codepen.io/paul-1997/pen/MWLaMva?editors=0010) |
| SHUO | [CodePen](https://codepen.io/xrzarxkl-the-reactor/pen/gOqbdxg) |
| 小夏 | [CodePen](https://codepen.io/michaelhsia/pen/eYxJYeZ) |
| 阿榮 | [Codepen](https://codepen.io/codeitaday/pen/wvNMvbw) |
| MY | [Codepen](https://codepen.io/ahmomoz/pen/JjxGowz?editors=1111) |
| Eden | [Codepen](https://codepen.io/iseden/pen/JjxGdNj) |
| yu.t_liu | [Codepen](https://codepen.io/YuT200053/pen/LYqGpWL?editors=0010) |
| Tina02 | [CodePen](https://codepen.io/chjitlox-the-bashful/pen/qBgEBPQ) |
| smalljie | [CodePen](https://codepen.io/smalljie/pen/dyaGOxv) |
| Fabio20 | [CodePen](https://codepen.io/fabio7621/pen/wvNMJMv?editors=1010) |
| Yijing | [CodePen](https://codepen.io/Yi-Jing-71080635/pen/LYqGWWg?editors=0011) |
| Sponge | [CodePen](https://codepen.io/biunpujm-the-flexboxer/pen/RwvrZWv?editors=1011) |
| jiayu | [CodePen](https://codepen.io/fjqxaznl-the-reactor/pen/GRzoOQB?editors=0011) |
| noah | [CodePen](https://codepen.io/lch1222/pen/qBgbpQg?editors=0011) |
| Oria | [CodePen](https://codepen.io/kajing/pen/zYerjrE?editors=0011) |
| 白夜 | [CodePen](https://codepen.io/Wei903/pen/PoVZgoL?editors=0012) |
| yuling | [CodePen]([Codepen](https://codepen.io/igzdflpu/pen/dyaGLWg)) |
| peggy | [CodePen](https://codepen.io/peggylai/pen/OJdMeJQ?editors=1111) |
| Iris | [CodePen](https://codepen.io/iris831206/pen/wvNMLpQ) |
| xuan | [CodePen](https://codepen.io/xuan0915/pen/MWLywJG?editors=0012) |
| nini1202desu | [CodePen](https://codepen.io/tvxq5206/pen/RwvaWrZ?editors=0011) |
| Peng | [CodePen](https://codepen.io/H-Peng/pen/vYbGGZN?editors=0010) |
| Vivian2857 | [CodePen](https://codepen.io/uojbohed-the-solid/pen/YzBqqYy?editors=0110) |
| hsu0921 | [CodePen](https://codepen.io/HSUANIN0327/pen/MWLyyEB) |
| Daylily | [CodePen](https://codepen.io/daylily/pen/XWOddvv) |
| 精靈 | [CodePen](https://codepen.io/justafairy/pen/ExrKyyj) |
| JasonFu | [CodePen](https://codepen.io/jie-Fu/pen/mdvPrqg?editors=1010) |
| 阿賀#3700 | [CodePen](https://codepen.io/sungho/details/gOqrwWJ) |
| Leo | [CodePen](https://codepen.io/Aruminiya/pen/WNPwopE) |
| gebyman | [CodePen](https://codepen.io/gebyman/pen/ZEwWBgP?editors=0011) |
| hsiu8767 | [CodePen](https://codepen.io/hsiu8767/pen/JjxXYJR?editors=0011)
| 歐陽龍龍#1061 |[CodePen](https://codepen.io/dizzydog-rgb/pen/gOqrRdj)|
| Mattie |[CodePen](https://codepen.io/mattielin/pen/JjxXybM)|
| shiro |[CodePen](https://codepen.io/chenghsienwang/pen/XWOdePG)|
| 阿維#2569 |[CodePen](https://codepen.io/iijojpli-the-looper/pen/bGzpOzV?editors=0011)|
| jimmy.0706 |[CodePen](https://codepen.io/WeiJun-Mao/pen/qBgZjNZ?editors=0010)|
|Joy chiang|[CodePen](https://codepen.io/fwysphbw-the-vuer/pen/VwgjwWP?editors=0011)|
|RX00|[CodePen](https://codepen.io/llqzknqv-the-styleful/pen/YzBqMBB?editors=1011)|
|jerry|[CodePen](https://codepen.io/ildkosxk-the-encoder/pen/LYqZMKr?editors=0010)|
|davidtt|[CodePen](https://codepen.io/David-Tsai/pen/yLZaaYm?editors=0011)|
|郭芙蘭#6374|[CodePen](https://codepen.io/flora_Kuo/pen/XWOjyZQ?editors=0011)|
|Cosmos|[CodePen](https://codepen.io/violet7755/pen/zYeoGdP)|
|OSN|[Codepen](https://codepen.io/osncodepen/pen/PoVbKPO?editors=1112)|
|小廷|[Codepen](https://codepen.io/uyxkiake-the-selector/pen/QWYGByv?editors=0011)|
|hsuhsusophie|[Codepen](https://codepen.io/hsuhsusophie/pen/abXBQza)|
|Rochel|[Codepen](https://codepen.io/rochelwang1205/pen/QWYdwNB?editors=1111)|
|shcopy|[Codepen](https://codepen.io/shcopy/pen/QWYpREz)|
|_Luna|[Codepen](https://codepen.io/sfctsolp-the-sasster/pen/poGeMYQ?editors=0011)|
|_shun0130|[Codepen](https://codepen.io/koba60052ww/pen/YzBNgmX?editors=0011)|
| shawey.1a2b | [Codepen](https://codepen.io/Shawey/pen/NWoaXLx) |
| Hank._.z | [Codepen](https://codepen.io/linoiaby-the-sans/pen/zYePdzZ?editors=1111) |
|ChrisSQR|[Codepen](https://codepen.io/ChrisSQR/pen/GRzOvwL)|
|angela9741|[Codepen](https://codepen.io/coding-angela25/pen/NWoBNzE?editors=0010)
|macihuang|[Codepen](https://codepen.io/macy1215/pen/gOqjmNg)|
|sunny_08149|[Codepen](https://codepen.io/vjgpcfpk-the-builder/pen/BaMPvKN)|
|bf_tsai|[Codepen](https://codepen.io/BF-Tsai/pen/QWYVWRj)|
| NathanJames |[Codepen](https://codepen.io/ufo060204/pen/vYbzdWX)|
| skypassion5000 |[Codepen](https://codepen.io/skypassion5000/pen/MWLPVgL?editors=0011)|
| 辣椒 |[Codepen](https://codepen.io/chilichen118/pen/YzBRZOR)|