Skip to content

Commit

Permalink
Translation zh-TW answer 84
Browse files Browse the repository at this point in the history
  • Loading branch information
sexyoung committed Jul 2, 2021
1 parent e877ade commit 45f0efb
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions zh-TW/README_zh-TW.md
Original file line number Diff line number Diff line change
Expand Up @@ -2656,4 +2656,36 @@ console.log(person)
</p>
</details>

---
###### 84. 將會輸出什麽內容?

```javascript
function checkAge(age) {
if (age < 18) {
const message = "Sorry, you're too young."
} else {
const message = "Yay! You're old enough!"
}

return message
}

console.log(checkAge(21))
```

- A: `"Sorry, you're too young."`
- B: `"Yay! You're old enough!"`
- C: `ReferenceError`
- D: `undefined`

<details><summary><b>答案</b></summary>
<p>

#### 答案: C

`const``let`定義的變數是具有**區塊作用域**的,區塊是大括號(`{}`)之間的任何東西, 即上述情況`if / else`語句的大括號。由於區塊作用域,我們無法在定義的塊之外引用變數,因此拋出`ReferenceError`

</p>
</details>

---

0 comments on commit 45f0efb

Please sign in to comment.