JavaScript Practice Questions
CORE PROGRAMMING CONSTRUCTS
Section A: Basic Arithmetic & Geometry
1. Solving Arithmetic Problems
Write a JavaScript program that declares two variables, assigns them numeric values, and
outputs their sum, difference, product, and quotient using the [Link]() function.
2. Calculating Area, Volume, etc.
Write a JavaScript function calculateCircleArea(radius) that takes the radius of a
circle as an argument and returns its area. (Hint: Use [Link])
Write a program that calculates the volume of a cylinder. Define variables for radius and
height , and print the result to the console.
Section B: Conditional Logic & Comparisons
3. Comparisons
Write a JavaScript program using if-else conditional structures that takes a student's test
score as input. If the score is 33 or higher, output "Pass". Otherwise, output "Fail".
Create a program that compares two numbers. If they are equal, print "Numbers are equal". If
the first is greater, print "First number is larger", and if the second is greater, print "Second
number is larger".
Section C: Iterative Structures (Loops)
4. Finding Factorial of a Number
Write a JavaScript program using a for loop to calculate and print the factorial of a given
positive integer n (e.g., if n=5, output 5 × 4 × 3 × 2 × 1 = 120).
5. Printing Series
Write a loop that prints the first 10 even numbers as a series (2, 4, 6, 8, 10...).
Create a script that prints a descending series of numbers from 100 down to 10, decrementing
by 10 each time.
6. Printing Table of a Number
Write a JavaScript function printTable(number) that takes an integer as an argument and
prints its complete multiplication table up to 10.
Section D: Arrays & Data Management
7. Finding the Largest or Smallest Number
Write a program that defines an array of five numbers. Use a loop to iterate through the array
and find the largest number within it.
Write a function findSmallest(arr) that takes an array as input and returns the smallest
number.
8. Searching for an Element
Create an array of your favorite subjects. Write a JavaScript program that uses a loop to
search for the word "Physics" in the array. If it is found, print "Element Found", otherwise print
"Element Not Found".
9. Sorting a List
Write a JavaScript program to sort an array of integers in ascending order. (Challenge: Try
writing the logic using nested loops, or use the built-in .sort() method).
Teacher's Note: Always practice good coding habits. Use clear variable names (like
studentMarks instead of just x ), and write brief comments above your functions to explain
what they do. You've got this!