---
# System prepended metadata

title: frontend

---

# frontend

## Q1. 印金字塔
https://jsfiddle.net/gcL2mx0f/

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

:::spoiler
```
const printPyramid = (rows) => {
    
}

printPyramid(5);
```
:::


---

## Q2. JSON 資料處理
https://jsfiddle.net/qm5fx18w/



:::spoiler Data
```javascript=
const resource = '{"success":"true","result":{"resource_id":"F-D0047-061","fields":[{"id":"contentDescription","type":"String"},{"id":"datasetDescription","type":"String"},{"id":"locationsName","type":"String"},{"id":"dataid","type":"String"},{"id":"locationName","type":"String"},{"id":"geocode","type":"Double"},{"id":"lat","type":"Double"},{"id":"lon","type":"Double"},{"id":"elementName","type":"String"},{"id":"description","type":"String"},{"id":"startTime","type":"Timestamp"},{"id":"endTime","type":"Timestamp"},{"id":"dataTime","type":"Timestamp"},{"id":"value","type":"String"},{"id":"measures","type":"String"}]},"records":{"locations":[{"datasetDescription":"臺灣各縣市鄉鎮未來3天(72小時)逐3小時天氣預報","locationsName":"臺北市","dataid":"D0047-061","location":[{"locationName":"南港區","geocode":"63000090","lat":"25.056317","lon":"121.59849","weatherElement":[{"elementName":"T","description":"溫度","time":[{"dataTime":"2022-02-17 12:00:00","elementValue":[{"value":"20","measures":"攝氏度"}]},{"dataTime":"2022-02-17 15:00:00","elementValue":[{"value":"20","measures":"攝氏度"}]},{"dataTime":"2022-02-17 18:00:00","elementValue":[{"value":"18","measures":"攝氏度"}]},{"dataTime":"2022-02-17 21:00:00","elementValue":[{"value":"17","measures":"攝氏度"}]},{"dataTime":"2022-02-18 00:00:00","elementValue":[{"value":"17","measures":"攝氏度"}]},{"dataTime":"2022-02-18 03:00:00","elementValue":[{"value":"17","measures":"攝氏度"}]},{"dataTime":"2022-02-18 06:00:00","elementValue":[{"value":"16","measures":"攝氏度"}]},{"dataTime":"2022-02-18 09:00:00","elementValue":[{"value":"18","measures":"攝氏度"}]},{"dataTime":"2022-02-18 12:00:00","elementValue":[{"value":"20","measures":"攝氏度"}]},{"dataTime":"2022-02-18 15:00:00","elementValue":[{"value":"19","measures":"攝氏度"}]},{"dataTime":"2022-02-18 18:00:00","elementValue":[{"value":"18","measures":"攝氏度"}]},{"dataTime":"2022-02-18 21:00:00","elementValue":[{"value":"17","measures":"攝氏度"}]},{"dataTime":"2022-02-19 00:00:00","elementValue":[{"value":"17","measures":"攝氏度"}]},{"dataTime":"2022-02-19 03:00:00","elementValue":[{"value":"17","measures":"攝氏度"}]},{"dataTime":"2022-02-19 06:00:00","elementValue":[{"value":"17","measures":"攝氏度"}]},{"dataTime":"2022-02-19 09:00:00","elementValue":[{"value":"17","measures":"攝氏度"}]},{"dataTime":"2022-02-19 12:00:00","elementValue":[{"value":"18","measures":"攝氏度"}]},{"dataTime":"2022-02-19 15:00:00","elementValue":[{"value":"17","measures":"攝氏度"}]},{"dataTime":"2022-02-19 18:00:00","elementValue":[{"value":"16","measures":"攝氏度"}]},{"dataTime":"2022-02-19 21:00:00","elementValue":[{"value":"15","measures":"攝氏度"}]},{"dataTime":"2022-02-20 00:00:00","elementValue":[{"value":"14","measures":"攝氏度"}]},{"dataTime":"2022-02-20 03:00:00","elementValue":[{"value":"13","measures":"攝氏度"}]},{"dataTime":"2022-02-20 06:00:00","elementValue":[{"value":"12","measures":"攝氏度"}]},{"dataTime":"2022-02-20 09:00:00","elementValue":[{"value":"12","measures":"攝氏度"}]}]},{"elementName":"PoP6h","description":"6小時降雨機率","time":[{"startTime":"2022-02-17 12:00:00","endTime":"2022-02-17 18:00:00","elementValue":[{"value":"90","measures":"百分比"}]},{"startTime":"2022-02-17 18:00:00","endTime":"2022-02-18 00:00:00","elementValue":[{"value":"70","measures":"百分比"}]},{"startTime":"2022-02-18 00:00:00","endTime":"2022-02-18 06:00:00","elementValue":[{"value":"90","measures":"百分比"}]},{"startTime":"2022-02-18 06:00:00","endTime":"2022-02-18 12:00:00","elementValue":[{"value":"80","measures":"百分比"}]},{"startTime":"2022-02-18 12:00:00","endTime":"2022-02-18 18:00:00","elementValue":[{"value":"20","measures":"百分比"}]},{"startTime":"2022-02-18 18:00:00","endTime":"2022-02-19 00:00:00","elementValue":[{"value":"70","measures":"百分比"}]},{"startTime":"2022-02-19 00:00:00","endTime":"2022-02-19 06:00:00","elementValue":[{"value":"100","measures":"百分比"}]},{"startTime":"2022-02-19 06:00:00","endTime":"2022-02-19 12:00:00","elementValue":[{"value":"90","measures":"百分比"}]},{"startTime":"2022-02-19 12:00:00","endTime":"2022-02-19 18:00:00","elementValue":[{"value":"80","measures":"百分比"}]},{"startTime":"2022-02-19 18:00:00","endTime":"2022-02-20 00:00:00","elementValue":[{"value":"90","measures":"百分比"}]},{"startTime":"2022-02-20 00:00:00","endTime":"2022-02-20 06:00:00","elementValue":[{"value":"100","measures":"百分比"}]},{"startTime":"2022-02-20 06:00:00","endTime":"2022-02-20 12:00:00","elementValue":[{"value":"100","measures":"百分比"}]}]}]}]}]}}';
```
:::


