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

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
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

Post by answerhappygod »

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>
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply