DEV Community

Abinaya V
Abinaya V

Posted on

javascript scenario questions(Variables,Operators,conditional statements)

1.you building a login system.store username and password in variables and check whether both are filled.

2.creat variables to store a product's name,price,and stock.print a message like:
"iphone cost ₹60000 and only 5 left in stock".

3.store a student's marks in 3 subject and calculate total.

4.Swap two numbers without using a third variable

5.Create a variable that stores whether a user is logged in or not and show a welcome message.

6.An e-commerce website gives a 10% discount.calculate final price.

7.Check whether a number is even or odd using operator.

8.Compare two passwords entered by user.

Image descriptio<br>
n

9.A person is eligible to vote if age>=18.write condition

10.Use logical AND to check:
-User is logged in
-User is admin
** Then allow dashboard acces**

11.Create a function that calculate total cart amount.

12.create a function to greet a user by name.

13.Create a function to convert celsius to Fahrenheit.

14.Create a function that returns the largest of two numbers.

15.Create a function to calculate EMI for a loan.(TBD)

16. If user role is "admin" show admin panel,else show user dashboard.

17. check if number is positive,negative, or zero.

*18. Check if a year is leap year. *

*19. Movie ticket pricing: Child(<12)-₹100 Adult-₹200. *

20. If marks >=90-Grade A 75-Grade B else-Fail.

Top comments (0)