JavaScript Basic Coding Test - Set 1
Total Marks: 50
Duration: 2 Hours
Part 1: Descriptive Questions (20 Marks)
1. Explain the difference between var, let, and const in JavaScript with examples. (3)
2. What is the purpose of the typeof operator? Provide two examples. (2)
3. Differentiate between for...of and for...in loops in JavaScript with examples. (3)
4. What is the do...while loop? How is it different from the while loop? Explain with an
example. (3)
5. What is the ternary operator? Write an example where it is used. (2)
6. State two advantages of using template literals compared to traditional string
concatenation. (2)
7. What is the difference between == and === operators? Why is === recommended?
(2)
8. What is the use of break and continue in loops? Explain with examples. (3)
Part 2: Coding Questions (30 Marks)
1. Write a code snippet to check if a given number is positive, negative, or zero. Print
the result. (3)
2. Using a for loop, print numbers from 1 to 10 in the console. (2)
3. Create an object representing a Book with title, author, and year. Print each property
separately. (3)
4. Given a month number (1-12), print the corresponding season ("Winter", "Spring",
"Summer", "Fall"). (4)
5. Given an age, check if the person is eligible to vote (18 or above) and print "Eligible"
or "Not Eligible". (3)
6. Create an array of numbers and perform the following operations: print the array, add
a new element, remove the last element, and print the updated array. (3)
7. Write a program that shows the use of comparison operators (==, ===, !=, !==) and
prints the results. (4)
8. Given a string, print its length, convert it to uppercase, and extract the first 3
characters. (3)
9. Write a program that calculates the factorial of a number and prints the result. (3)
10. Using a for...in loop, iterate through an object and print its keys and values. (2)
JavaScript Basic Coding Test – Set 2
Total Marks: 50
Duration: 2 Hours
Part 1: Descriptive Questions (20 Marks)
1. Explain the concept of hoisting in JavaScript with an example. (3)
2. What is the purpose of the Math object in JavaScript? Name any four commonly used
Math methods. (3)
3. Differentiate between null and undefined in JavaScript. (2)
4. What are template literals? How are they better than string concatenation? Write an
example. (2)
5. Explain the difference between for...in and for...of loops in JavaScript with examples.
(3)
6. What are comparison operators in JavaScript? List and explain any three with
examples. (3)
7. What is the importance of using continue and break inside loops? Write a small
example for each. (2)
8. What is a switch statement and when is it preferred over multiple if-else statements?
(2)
Part 2: Coding Questions (30 Marks)
1. Write a JavaScript program to find the maximum of three numbers. (4)
2. Using a while loop, print all even numbers from 1 to 20. (3)
3. Create an object Student with properties name, age, and course. Print each property
separately. (3)
4. Given a string, count the number of vowels in it and print the count. (4)
5. Using the Math object, generate and print a random number between 1 and 100. (3)
6. Write a program to find whether a given year is a leap year or not. (3)
7. Using a for...of loop, print each element of an array of cities. (2)
8. Write a program to reverse a string and print the reversed string. (3)
9. Create an object with some key-value pairs and use a for...in loop to print both keys
and values. (2)
10. Write a program to check if a given number is prime or not. (3)
JavaScript Basic Coding Test – Set 3
Total Marks: 50
Duration: 2 Hours
Part 1: Descriptive Questions (20 Marks)
1. What is the difference between == and === in JavaScript? Explain with examples. (3)
2. Define a JavaScript object. How is it different from an array? (2)
3. Explain what is meant by block scope in JavaScript with an example. (3)
4. Describe the working of the switch statement in JavaScript with an example. (3)
5. What are logical operators? List and explain any two logical operators with examples.
(3)
6. What is a ternary operator? Write a simple example to explain. (2)
7. Explain the purpose of the typeof operator with examples. (1)
8. What is the difference between var, let, and const in JavaScript? Provide examples.
(3)
Part 2: Coding Questions (30 Marks)
1. Write a JavaScript program to check whether a number is odd or even. (3)
2. Create an object Car with properties brand, model, and year. Print the object
properties to the console. (3)
3. Using a for loop, print numbers from 50 to 40 in descending order. (2)
4. Given a temperature in Celsius, convert it to Fahrenheit and print the result. (4)
5. Write a program that takes a string and checks if it is a palindrome (same backward
and forward). (4)
6. Use a while loop to print multiples of 5 up to 50. (2)
7. Using a for...in loop, iterate through an object and print its properties and values.
(3)
8. Write a JavaScript program to find the factorial of a given number using a for loop.
(3)
9. Create a program that generates a random integer between 1 and 10 and prints it. (3)
10. Write a program to find the largest among two given numbers using the ternary
operator. (3)
JavaScript Basic Coding Test – Set 4
Total Marks: 50
Duration: 2 Hours
Part 1: Descriptive Questions (20 Marks)
1. What are the different data types available in JavaScript? Give examples. (3)
2. Explain the difference between null and undefined in JavaScript. (2)
3. Describe how if, else if, and else conditional statements work in JavaScript.
Provide an example. (3)
4. Explain the purpose of the break and continue statements in loops with examples.
(3)
5. What is the significance of using const in JavaScript? Can we reassign values to a
const variable? (2)
6. Write a short note on type coercion in JavaScript. Give an example. (2)
7. What are template literals? How are they different from string concatenation? (2)
8. What is the output of typeof NaN and why? (3)
Part 2: Coding Questions (30 Marks)
1. Write a program to check whether a number is divisible by both 3 and 5. (3)
2. Print all even numbers from 1 to 20 using a for loop. (2)
3. Create a simple calculator using if-else that performs addition, subtraction,
multiplication, or division based on two numbers and an operator. (4)
4. Write a program that prints the multiplication table of a given number using a loop.
(3)
5. Write a program that converts a given number of days into years, months, and days
(Assume 1 year = 365 days, 1 month = 30 days). (4)
6. Create an object student with properties name, rollNo, and grade. Print all values
using a for...in loop. (3)
7. Use a do...while loop to print numbers from 1 to 5. (2)
8. Write a program to check if a given year is a leap year or not. (3)
9. Write a program to compare two strings and check if they are equal (case-sensitive).
(3)
10. Write a program to find the cube of a number and display the result. (3
JavaScript Basic Coding Test – Set 5
Total Marks: 50
Duration: 2 Hours
Part 1: Descriptive Questions (20 Marks)
1. Describe the concept of "hoisting" in JavaScript. How does it work with var, let, and
const? (3)
2. Explain the difference between == and === in JavaScript. Provide examples to support
your explanation. (3)
3. Describe how if, else if, and else conditional statements work in JavaScript.
Provide an example. (3)
4. Explain the concept of closures in JavaScript. Provide an example to demonstrate it.
(3)
5. What is a JavaScript "global object"? Explain its use with an example. (2)
6. What is the purpose of the this keyword in JavaScript? Provide an example. (3)
7. What are arrow functions in JavaScript, and how do they differ from regular
functions? (3)
8. Explain the concept of hoisting in JavaScript with an example. (3)
Part 2: Coding Questions (30 Marks)
1. Write a program that checks if a given number is a prime number or not. (4)
2. Write a function that accepts a string and returns it in reverse order. (3)
3. Create a person object with firstName, lastName, and age properties. Write a
method that calculates and returns the person's full name. (4)
4. Write a program to find the largest of three given numbers. (3)
5. Write a program that calculates the area of a rectangle (length * width) and prints the
result. (2)
6. Create a student object with properties name, age, marks. Write a function to
calculate the average marks of the student. (4)
7. Write a program that finds whether a string is a palindrome or not. (4)
8. Write a function that returns the factorial of a given number using recursion. (3)
9. Write a program that prints the Fibonacci sequence up to the 10th term. (3)
10. Write a program that accepts a number and checks if it is a perfect square. (3)
JavaScript Basic Coding Test – Set 6
Total Marks: 50
Duration: 2 Hours
Part 1: Descriptive Questions (20 Marks)
1. Explain the difference between function scope and block scope in JavaScript. Provide
examples. (3)
2. What is OOPs? (3)
3. Explain type coercion in JavaScript. Provide an example. (3)
4. What is a closure in JavaScript? Explain with an example. (3)
5. What is the difference between == and ===? (2)
6. What is NaN in JavaScript? How do you check if a value is NaN? (2)
7. Explain short-circuit evaluation in JavaScript with an example. (2)
8. What are template literals? Write an example where they are used. (2)
Part 2: Coding Questions (30 Marks)
1. Write a program to check if a number is positive, negative, or zero. (3)
2. Write a for loop that prints all odd numbers from 1 to 50. (3)
3. Create an object Employee with properties name, designation, and salary. Print
each property separately. (3)
4. Write a JavaScript program to count the number of vowels in a given string. (3)
5. Write a program that converts a number into words (Example: 123 → "One Two
Three"). (4)
6. Write a program that accepts a string and checks if it is a palindrome (Example:
"madam" → "Palindrome", "hello" → "Not a Palindrome"). (3)
7. Write a JavaScript program to calculate the sum of digits of a given number. (3)
8. Write a program that checks if a given year is a leap year. (3)
9. Generate and print a random number between 1 and 50 using the Math object. (2)
10. Write a JavaScript program to find the largest of three given numbers. (3)