how to shorten conditional statements javascript
//XCal - Javascript Inline Conditional Sample (condition brackets only for clarity)
// v-? = Conditional Operator
// v v-: = True/False result value separator
//Format = v-Condition-v ? v-When True-v : v-When False-v
var vResult = (null == null) ? 'Condition True' : 'Condition False';
//vResult is now 'Condition True';
4.25
4
var canDrive = age > 16 ? 'yes' : 'no'
Thank you!
4
0
3.9
10
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>Write a JavaScript conditional statement to find the largest of five numbers</title>
</head>
<body>
</body>
</html>
Thank you!
10
0
Are there any code examples left?
New code examples in category Javascript