JavaScript Practice Questions (Using HTML)
Instructions (common for all questions):
Create an HTML file and write JavaScript code using the <script> tag.
Display output using [Link]() or innerHTML.
Section A: Variables & Data Types
Q1. Variable Declaration
Create an HTML page that declares variables using var, let, and const and displays their
values on the webpage.
Q2. Data Type Identification
Write an HTML-JavaScript program to declare variables of different data types ( number,
string, boolean) and display their data type using the typeof operator.
Q3. User Information Display
Create an HTML page that stores name, age, and city in variables and displays them in a
formatted manner.
Q4. Type Conversion
Write a JavaScript program in HTML to demonstrate:
String to Number conversion
Number to String conversion
Display both original and converted values.
Q5. Constant Value Program
Create an HTML page where a constant value of PI is declared and used to calculate the area
of a circle.
Section B: Operators
Q6. Arithmetic Operators
Create an HTML page that performs addition, subtraction, multiplication, division, and
modulus operations on two numbers and displays the results.
Q7. Assignment Operators
Write a JavaScript program in HTML demonstrating assignment operators (=, +=, -=, *=,
/=) with output after each operation.
Q8. Comparison Operators
Create an HTML page that compares two numbers using comparison operators and displays
whether:
Values are equal
One is greater than the other
Q9. Logical Operators
Write an HTML-JavaScript program to check whether a student is eligible for exam based
on:
Marks ≥ 40
Attendance ≥ 75%
Use logical operators.
Q10. Increment and Decrement
Create an HTML page to demonstrate:
Pre-increment
Post-increment
Pre-decrement
Post-decrement
Section C: Control Statements
Q11. Even or Odd
Write an HTML-JavaScript program using if-else to check whether a number is even or
odd.
Q12. Positive, Negative, or Zero
Create an HTML page to check whether a number is positive, negative, or zero using
conditional statements.
Q13. Grade Calculator
Write a JavaScript program in HTML that assigns grades based on marks:
≥ 90 → A
≥ 75 → B
≥ 60 → C
Else → Fail
Q14. Largest of Three Numbers
Create an HTML-JavaScript program using if-else to find the largest of three numbers.
Q15. Voting Eligibility
Write an HTML page to check voting eligibility based on age using if-else.
Section D: Loops
Q16. Number Series
Create an HTML page that displays numbers from 1 to 10 using a for loop.
Q17. Multiplication Table
Write an HTML-JavaScript program to display the multiplication table of a given number
using a loop.
Q18. Sum of Natural Numbers
Create an HTML page to calculate the sum of first n natural numbers using a loop.
Q19. Reverse a Number
Write a JavaScript program in HTML to reverse a given number using a loop.
Q20. Factorial Program
Create an HTML-JavaScript program to calculate the factorial of a number.
Section E: Combined Practice (Applied Logic)
Q21. Simple Calculator
Create an HTML page that performs basic calculator operations using operators and control
statements.
Q22. Discount Calculator
Write an HTML-JavaScript program to calculate discount:
10% if amount > 2000
5% if amount > 1000
Q23. BMI Calculator
Create an HTML page to calculate BMI and display health category using if-else.
Q24. Login Validation
Write an HTML-JavaScript program to validate username and password using conditional
statements.
Q25. Mini Result System
Create an HTML page that:
Accepts marks of 3 subjects
Calculates total and percentage
Displays pass/fail result