#### 關於邏輯運算子 - OR - || - 假設條件為兩個以上,僅需要滿足任何1項即獲得:`true`該判斷式成立條件。 這正是 `||` 的邏輯。 #### 情境 - 百貨公司促銷中,只要是年度 VIP 或當日敲費滿千: 即可獲得禮品一個,嘗試根據上述條件撰寫邏輯運算子 OR ``` javascript // JavaScript const isVip = false; const cost = 1001; const resault = isVip || cost >= 1000 ? true : false; console.log(resault); // true ``` - 以上述代碼為例,該會員不具備 VIP 身份,但金額 `>=` 1000 正滿足了 `||` , 只要一項目達成就 ok , 故這題的答案是 `true`
×
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