coding style How should one comment an if-else structure
How long can it take?
- if...else MDN
- Lesson 6 Even Smarter Scripts with ifâ€¦else and
Our new condition statement is then: "If the subtotal is greater than $200, then apply a 20% discount, else if the subtotal is greater than $100 apply a 10% discount, else if the subtotal is greater than $50 then apply a 5% discount, otherwise no discount is applied."
- With a multiple if else, if the first if is true, then it ignores the else (which contains all the other if statements), so you action less statements. Of course, in this case, that doesn't matter much. Computers are so fast nowadays that a few statements actioned when they don't need to won't slow things down! But those of us who remember the days when even large computers memory was
- Statement that is executed if condition is falsy and the else clause exists. Can be any statement, including block statements and further nested if statements. Description