Foundations

If and Else

If and Else

if handles the true path. else handles everything that does not pass the condition, giving the program a clear fallback path.

Your task: Use the provided age to set accessLabel. Adults should receive "adult"; everyone else should receive "minor". Log the selected label.

Free with a JS Exercises account

Sign in to start coding, run your solution, and keep your progress saved for later. No payment needed.

By continuing, you agree to our Terms and Privacy Policy. We'll send occasional product updates and news. You can unsubscribe anytime.

If and Else

if handles the true path. else handles everything that does not pass the condition, giving the program a clear fallback path.

Your task: Use the provided age to set accessLabel. Adults should receive "adult"; everyone else should receive "minor". Log the selected label.

Free with a JS Exercises account

Sign in to start coding, run your solution, and keep your progress saved for later. No payment needed.

By continuing, you agree to our Terms and Privacy Policy. We'll send occasional product updates and news. You can unsubscribe anytime.

Console

Run code to see output.