Welcome to JavaScript Finder
Javascript If Statement
If you're writing code, often you will need to use conditional statements. An If statement looks at a piece of code to see if it is true or false. Javascript If statements are a test of a condition.
JavaScript : If Statement
<script language="JavaScript">
<!--
var UserName = "Bobby";
if (UserName == "Bobby") {
document.write("Hello Bobby!");
}
-->
</script>
UserName does equal Bobby. So the output would be Hello Bobby!
Javascript If Else Statement
JavaScript : If Else Statement
<script language="JavaScript">
<!--
var UserName = "Mike";
if (UserName == "Bobby") {
document.write("Hello Bobby!");
}
else {
document.write("Not Bobby huh?");
}
-->
</script>
UserName does not equal Bobby. So the output would be Not Bobby huh?