Use if statement to compare the numbers : If « Statement « JavaScript Tutorial






<html>
<head>
<title>Use if statement to compare the numbers</title>
<script>
var temp = 0;
var perfectTemp = 65;


temp = Math.floor(Math.random() * 100) + 1;
alert ("It's " + temp + " degrees outside. ");

if (temp < perfectTemp){
  alert("Low!!");
}

</script>
</head>

<body>
<h3>Hit Reload to see another temperature</h3>
</body>
</html>








3.2.If
3.2.1.Conditionals
3.2.2.if...else
3.2.3.Use if statement to compare the numbers
3.2.4.Use if/else to check the returning value from a confirm dialog
3.2.5.Use if statement to check the returning value from a confirm dialog
3.2.6.Nested if statement
3.2.7.if...then...else...if