將「if」改寫成「?」
重要性:5
使用條件運算子「?」改寫這個「if」
let result;
if (a + b < 4) {
result = 'Below';
} else {
result = 'Over';
}
let result = (a + b < 4) ? 'Below' : 'Over';
使用條件運算子「?」改寫這個「if」
let result;
if (a + b < 4) {
result = 'Below';
} else {
result = 'Over';
}
let result = (a + b < 4) ? 'Below' : 'Over';