Use if statement to check string value - Javascript Statement

Javascript examples for Statement:Quiz

Description

Use if statement to check string value

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<p id="demo"></p>

<script>
var firstName = "Tom";

if (firstName === "TOM") {
    document.getElementById("demo").innerHTML = "Hello TOM!";
} else {//from   w w  w.j av a 2  s.  c  o m
    document.getElementById("demo").innerHTML = "You're not TOM!";
}
</script>

</body>
</html>

Related Tutorials