1if (condition1) {
2 // code to be executed if condition1 is true
3} else if (condition2) {
4 // code to be executed if the condition1 is false and condition2 is true
5} else {
6 // code to be executed if the condition1 is false and condition2 is false
7}
1if (5 < 10) {
2 console.log("5 is less than 10");
3} else {
4 console.log("5 is now bigger than 10")
5}
1//XCal - Javascript Inline Conditional Sample (condition brackets only for clarity)
2// v-? = Conditional Operator
3// v v-: = True/False result value separator
4//Format = v-Condition-v ? v-When True-v : v-When False-v
5var vResult = (null == null) ? 'Condition True' : 'Condition False';
6//vResult is now 'Condition True';
1<!DOCTYPE html>
2<html>
3<head>
4<meta charset=utf-8 />
5<title>Write a JavaScript conditional statement to find the largest of five numbers</title>
6</head>
7<body>
8
9</body>
10</html>
11
12
1a=-5;
2b=-2;
3c=-6;
4d= 0;
5f=-1;
6if (a>b && a>c && a>d && a>f)
7{
8 console.log(a);
9}
10else if (b>a && b>c && b>d && b>f)
11{
12 console.log(b);
13}
14else if (c>a && c>b && c>d && c>f)
15{
16 console.log(c);
17}
18else if (d>a && d>c && d>b && d>f)
19{
20 console.log(d);
21}
22else
23{
24 console.log(f);
25}
26
27