---
tags: JS - 練習
---
# 【字串】 與 【for】、【forEach】 練習
## 使用 ''(單引號) 或 ``(Es6)
> 請使用以下參數操作,兩種方式都要
```
data: [
{
title: '比特幣',
content: '持續上漲中'
},
{
title: '以太幣',
content: '2.0準備出來摟!'
},
{
title: '幣安幣',
content: '社群活躍'
}
]
```
* 請串出“比特幣-持續上漲中”這種格式
* 請在「目前公告:最新資訊~」”這個字串的「最新資訊~」前面加上「比特幣-持續上漲中」
* 透過迴圈將三個幣種加入公告裡
```
目前公告:比特幣-持續上漲中、以太幣-2.0準備出來摟!、幣安幣-社群活躍 最新資訊~
```
# 迴圈練習
## for loop
> 請將答案console.log 出來
- 1~100
```
例如:
console.log(1)
console.log(2)
console.log(3)...
```
- 奇數並幫加上“答案-”的字串
```
例如:
console.log('答案-1')
console.log('答案-3')
console.log('答案-5')...
```
- 印出1~100,除以3餘數為2的值
```
例如:
console.log(2)
console.log(5)
console.log(8)...
```
- 九九乘法表
```
例如:
console.log(1x1=2)
console.log(1x2=2)
console.log(1x3=3)...
```
## forEach
> 請使用該Data操作
```
data: [
{
name: '小明',
age: 10,
number: 1
},
{
name: '小陳',
age: 24,
number: 2
},
{
name: '小王',
age: 16,
number: 3
}
]
```
- 將小王的age改成18
```
例如:
{
name: '小王',
age: 18,
number: 3
}
```
- 每筆資料裡面增加 money參數
```
例如:
{
name: '小王',
age: 18,
number: 3,
money: '100'
}
```