HI, I am working on javascript in HTML. I can get the promts toask for the name and age but i cant get the if and else statementsto work. Can you look at the javascript section in between the<script> </script> section and let me know what iam missing?
<!doctype html><html lang="en"> <head> <title></title> <link rel="stylesheet"type="text/css" href="css/style.css">
<script> var username = prompt("Enteryour name:"); var birth = prompt("Enteryour age "); if (birth < 40) { alert = "Hello " + username +" you are " + birth + "you are still young!"; } else (birth > 40) { console.log(birth + "you areold!"); alert = "Hello " + username +" you are " + birth + "you are old!"; } </script>
</head> <body> </body></html>
HI, I am working on javascript in HTML. I can get the promts to ask for the name and age but i cant get the if and else
-
answerhappygod
- Site Admin
- Posts: 899604
- Joined: Mon Aug 02, 2021 8:13 am
HI, I am working on javascript in HTML. I can get the promts to ask for the name and age but i cant get the if and else
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!