CodeLab
Tutorials For Everyone
Run
<!DOCTYPE html> <html> <head> <title>JavaScript console.warn() Function Tutorial - TutsInsider</title> <style> .main{ padding: 10px; } .main-heading{ background: #333333; color: #ffffff; padding: 20px; } .main-paragraph{ margin-top: -20px; padding: 20px; box-shadow: inset 0 0 3px 0 #2a73cc; } .main-button{ padding: 5px 10px; margin: 5px; border: none; border-radius: 5px; background: #333333; color: #ffffff; box-shadow: 0 0 3px 0 #333333; cursor: pointer; } </style> </head> <body> <div class="main"> <h2 class="main-heading">What is JavaScript console.warn() Function?</h2> <div class="main-paragraph"> <p>Press <strong>F12</strong> on your keyboard to open the Browser's console.</p> <p>Inside 'Console', you will see the output of the Script below.</p> <p><strong>Note: </strong> Reload the page to re-enter a different number or try a letter to see the results in the console.</p> </div> </div> <script> let user_age = prompt("Enter Your Age:"); if ( user_age < 15 ) { console.warn("Your age is : " + user_age ); console.warn("Its too early for you to learn JavaScript Programming."); } else if ( user_age > 15 ) { console.log("Your age is : " + user_age ); console.log("Its pretty easy for you to learn JavaScript Programming."); } else { console.warn("Please enter a valid age."); } </script> </body> </html>