# JavaScript 筆記 if if :如果 else if : if外的條件,第一個條件用if,剩下都用 else if else :if , else if 以外所有剩下的條件 ```javascript if (條件1) { 達成條件1後想要執行的結果 } else if (條件2) { 達成條件2後想要執行的結果 } else { 條件1、條件2以外,剩下的條件想執行的結果 } ``` 舉例 ```javascript let age = 20 if (age >= 18){ console.log("成年人") } else if (age >=13 && age < 18){ console.log("青少年") } else { console.log("兒童") }
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up