<!-- JavaScript:Basics plus code snippet 6. --> <!-- Conditional using multiple 'if' statements. --> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <!-- Code source: http://www.justfigures.co.uk/ --> <!-- A resource for web developers using XHTML, CSS, JavaScript, PHP --> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>View code snippet page</title> </head> <body> <script language="JavaScript" type="text/javascript"> //<![CDATA[ var temperature; temperature = window.prompt('Enter today\'s temperature', ''); temperature = parseFloat(temperature); // use of multiple 'if' statements // with the 'AND' comparison && if (temperature <= 0) {document.write('It is very cold')} if ((temperature > 0) && (temperature <= 15)) {document.write('It is cold')} if ((temperature > 15) && (temperature <= 25)) {document.write('It is a warm')} if (temperature > 25) {document.write('It is hot')} //]]> </script> </body> </html>