Mega Code Archive

 
Categories / JavaScript Tutorial / Statement
 

Nested if statement

< html> <head> <title>Nested if statement</title> <script> var temp = 0; temp = Math.floor(Math.random() * 100) + 1; alert ("It's " + temp + " degrees outside. "); if (temp < 70){   if (temp < 30){     alert("< 30");   } else {     alert(" between 30 and 70");   } } else {   if (temp > 85){     alert("> 85");   } else {     alert("between 85 and 70");   } } </script> </head> <body> <h3>Hit Reload to see another temperature</h3> </body> </html>