CodeLab
Tutorials For Everyone
Run
<!DOCTYPE html> <html> <head> <title>JavaScript console.log() 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.log() 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> try replacing the String or even you can use the numbers also, and then recheck the console after pressing 'Run' button.</p> </div> </div> <script> let user_age = prompt("Enter Your Age:"); if ( user_age < 15 ) { console.log("Your age is : " + user_age ); console.log("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.log("Please enter a valid age."); } </script> </body> </html>