DEV Community

Deva I
Deva I

Posted on

Javascript Scenario question using (variables, operators, conditional statements) - 2

1. Check number is even or odd:

PROGRAM:

OUTPUT:

2. Compare two passwords entered by user.

PROGRAM:

OUTPUT:

3. Write condition if person age >= 18 is eligible to vote:

PROGRAM:


OUTPUT:

4. Use logical AND to check:

▪️User is logged in

▪️User is admin Then allow dashboard access.

PROGRAM:

OUTPUT:

5.calculates total cart amount:

PROGRAM:

OUTPUT:

6. greet a user by name:

PROGRAM:

OUTPUT:

7. convert Celsius to Fahrenheit:

PROGRAM:

OUTPUT:

8. returns the largest of two numbers:

PROGRAM:

OUTPUT:

9. Check user role:

PROGRAM:

OUTPUT:

10. Check number is positive, negative, or zero:

PROGRAM:

OUTPUT:

11. Check a year is leap year:

PROGRAM:


OUTPUT:

12. Movie ticket pricing:child age below 12->100, adult age above 12->200:

PROGRAM:

OUTPUT:

13. If marks >= 90 Grade A,75→ Grade B else → Fail:

PROGRAM:

OUTPUT:

Top comments (0)