fixed examples (#21527)
made changes to examples to be more javascript standard
This commit is contained in:
@ -47,24 +47,25 @@ if (condition) {
|
|||||||
|
|
||||||
**Using** `if...else`:
|
**Using** `if...else`:
|
||||||
```javascript
|
```javascript
|
||||||
// If x=5 z=7 and q=42. If x is not 5 then z=19.
|
// If x=5 then z=7 and q=42 else z=19.
|
||||||
if (x == 5) {
|
if (x === 5) {
|
||||||
z = 7;
|
z = 7;
|
||||||
q = 42
|
q = 42;
|
||||||
else
|
}else{
|
||||||
z = 19;
|
z = 19;
|
||||||
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
**Using** `else if`:
|
**Using** `else if`:
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
if (x < 10)
|
if (x < 10){
|
||||||
return "Small number";
|
return "Small number";
|
||||||
else if (x < 50)
|
}else if (x < 50){
|
||||||
return "Medium number";
|
return "Medium number";
|
||||||
else if (x < 100)
|
}else if (x < 100){
|
||||||
return "Large number";
|
return "Large number";
|
||||||
else {
|
}else {
|
||||||
flag = 1;
|
flag = 1;
|
||||||
return "Invalid number";
|
return "Invalid number";
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user