Skip to content

Commit 151e309

Browse files
committed
Translation zh-TW answer 69
1 parent c7ff57c commit 151e309

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

zh-TW/README_zh-TW.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2156,4 +2156,31 @@ console.log(Symbol('foo') === Symbol('foo'));
21562156
</p>
21572157
</details>
21582158

2159+
---
2160+
2161+
###### 69. 將會輸出什麽內容?
2162+
2163+
```javascript
2164+
const name = 'Lydia Hallie';
2165+
console.log(name.padStart(13));
2166+
console.log(name.padStart(2));
2167+
```
2168+
2169+
- A: `"Lydia Hallie"`, `"Lydia Hallie"`
2170+
- B: `" Lydia Hallie"`, `" Lydia Hallie"` (`"[13x whitespace]Lydia Hallie"`, `"[2x whitespace]Lydia Hallie"`)
2171+
- C: `" Lydia Hallie"`, `"Lydia Hallie"` (`"[1x whitespace]Lydia Hallie"`, `"Lydia Hallie"`)
2172+
- D: `"Lydia Hallie"`, `"Lyd"`,
2173+
2174+
<details><summary><b>答案</b></summary>
2175+
<p>
2176+
2177+
#### 答案: C
2178+
2179+
使用 `padStart` 函數,我們可以在字串的前面加上填充字串。傳遞給此函數的參數是字串的總長度(包含填充字串)。字串 Lydia Hallie 的長度為 `12` , 因此 `name.padStart(13)` 在字串的開頭只會插入1個空格,因為 12 + 1 等於 13。
2180+
2181+
如果傳給 `padStart` 函數的參數小於字串的長度,則不會加上填充字串。
2182+
2183+
</p>
2184+
</details>
2185+
21592186
---

0 commit comments

Comments
 (0)