Conditional Ternary Operator tutorial in JavaScript
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, shrink-to-fit=no">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Conditional Ternary Operator JavaScript</title>
<script>
var a = 100;
var b;
(a == 100) ? b = "TRUE" : b = "FALSE";
document.write(b + "<br>");
b = (a == 101) ? "TRUE" : "FALSE";
document.write(b + "<br>");
b = "Value is " + (a == 100 ? "TRUE" : "FALSE");
document.write(b);
</script>
</head>
<body>
</body>
</html>
.png)
.png)
.png)
.png)
Comments
Post a Comment