It's not a rule but a good practice to always use brackets in your if statements, even if they are only one line. In the case of your code, they're actually required or you will see a syntax error in the console. Your code is also missing a closing curly brace. Here's how that should look.
if (a < 18) {
????document.write("Child");
} else if (a < 35) {
????document.write("Young");
} else if (a < 50) {
????document.write("Adult");
} else {
????document.write("Old");
}
Anywho, here's the whole thing with the corrections.
????
????
Problem: write a java script program in HTML which will accept entered ages from a user, if a user clicks on a display button a corresponding result will be displayed based on:
< 18 :Child,
< 35: Young,
< 50: Adult,
< 50: Old.
My soln so far:
the problem is when run the in a web-browser, it shows the 'text field & a display button', but when enter age and i click on the button, it doesn't display the desired output