Created
November 19, 2025 12:46
-
-
Save imjacobclark/62de91d23ec9cf085f8e79b69b28aade to your computer and use it in GitHub Desktop.
Masterclass
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <html> | |
| <head> | |
| </head> | |
| <body> | |
| <input type="text" id="user-age-input"> | |
| <button id="user-age-submit">Submit</button> | |
| <p id="user-age-feedback">Please enter your age in the input box above!</p> | |
| <input type="email" id="email-address"> | |
| </body> | |
| <script> | |
| const inputElement = document.getElementById("user-age-feedback"); | |
| function isUserOldEnoughToDrink(usersAge, legalDrinkingAge) { | |
| if (usersAge >= legalDrinkingAge) { | |
| inputElement.innerText = "User is able to buy alchohol"; | |
| inputElement.style.color = "green"; | |
| inputElement.style.backgroundColor = "black"; | |
| } else { | |
| inputElement.innerText = "User is not able to buy alchohol"; | |
| inputElement.style.color = "red"; | |
| inputElement.style.backgroundColor = "black"; | |
| } | |
| } | |
| const legalDrinkingAge = 18 | |
| let usersAge = null; | |
| document | |
| .getElementById("user-age-submit") | |
| .addEventListener("click", function () { | |
| usersAge = document.getElementById("user-age-input").value; | |
| isUserOldEnoughToDrink(usersAge, legalDrinkingAge); | |
| const emailAddress = document.getElementById("email-address").value; | |
| console.log(emailAddress.includes("@")); | |
| alert( | |
| emailAddress.includes("@") === true && | |
| emailAddress.includes(".com") === true ? | |
| "Email is valid" : | |
| "Email is not valid" | |
| ) | |
| }); | |
| </script> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment