Javascript examples for Statement:if
Return a month name using a Javascript if statement
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> </head> <body> <div id="months"> unchanged/*from w w w. j a va 2 s .com*/ </div> <script type="text/javascript"> window.onload = function() { var monthName = getMonth(12); document.getElementById("months").innerHTML = monthName; }; function getMonth(month) { var monthName; if (month === 12) { monthName = 'December'; } return monthName; } </script> </body> </html>