Formatting examples, added example based on note (#21186)

would like some feedback on my extra example :)
This commit is contained in:
DC
2018-11-22 00:26:07 +11:00
committed by Paul Gamble
parent 610c4303c1
commit adad522465

View File

@ -73,16 +73,23 @@ const num = someCondition ? 1 : 2;
```
**Using** `else if`:
```javascript
if (x < 10){
// Categorising any number x as a small, medium, or large number
if (x < 10)
return "Small number";
}else if (x < 50){
else if (x < 50)
return "Medium number";
}else if (x < 100){
else if (x < 100)
return "Large number";
}else {
else {
flag = 1;
return "Invalid number";
}
}
```
**Using** `if` **alone**:
```javascript
// This function can also act as a Boolean
if (x < 30) {
return "true";
}