Verbal Questions
Variables
1. What is a variable in JavaScript, and how do you declare one?
2. What are the differences between var, let, and const in JavaScript?
3. Write code to declare a variable name and assign it the value "John".
4. What will happen if you try to change the value of a const variable?
Data Types
1. What are the basic data types available in JavaScript?
2. How can you check the data type of a variable in JavaScript?
3. What is the difference between null and undefined in JavaScript?
4. Write a program to demonstrate the difference between a number and a string.
Operators
1. What is the difference between == and === in JavaScript?
2. What does the typeof operator do in JavaScript? Write an example.
3. Write code to demonstrate the use of arithmetic operators (+, -, /, %).
4. What will be the result of 10 + "5"? Why?
5. Write a program to swap two numbers using a temporary variable and using arithmetic
operators.
Conditional Statements
1. Write a program to check if a number is positive, negative, or zero.
2. What is the difference between if and else if? Write an example.
3. Write a program to check whether a given year is a leap year.
4. What is a ternary operator? Write code to demonstrate its use.
5. Write a program to check whether a number is even or odd using an if statement.
Practical Questions
Variables (10 Questions)
1. Declare a variable age and assign your age to it.
2. Change the value of a let variable and observe the output.
3. Try reassigning a const variable and note the error.
4. Write a program that declares multiple variables in one line and assigns values to them.
5. Create a variable without initializing it and log its value.
6. Write code to demonstrate the difference between var, let, and const scopes.
7. What happens if you declare a variable without using var, let, or const? Try it.
8. Write a program to store your full name in two separate variables and combine them into one.
9. Create a global variable and a local variable with the same name. Log both.
10. Use template literals to print a sentence containing variables.
Data Types (10 Questions)
11. Write a program to log the type of different variables: number, string, boolean, null, undefined,
object.
12. Create a variable that holds an array of numbers and log its type.
13. Write code to convert a number to a string and vice versa.
14. Declare a variable with the value null and check its type.
15. Use the typeof operator on different types and print the results.
16. Write a program to demonstrate type coercion by concatenating a string and a number.
17. Declare an object with properties and log its type.
18. Write code to check if a variable is undefined.
19. Use Array.isArray to verify if a variable is an array.
20. Create a variable with a boolean value and use it in an if statement.
Operators (10 Questions)
21. Write a program to perform addition, subtraction, multiplication, and division of two numbers.
22. Use the modulus operator to find the remainder of a division.
23. Write code to demonstrate the difference between == and ===.
24. Write a program to swap two variables without using a temporary variable.
25. Use comparison operators to check if a number is greater than, less than, or equal to another number.
26. Use logical operators (&&, ||, !) in a program to evaluate conditions.
27. Write a program to increment and decrement a variable using ++ and --.
28. Use the ternary operator to decide whether a number is positive or negative.
29. Write code to check if a number is within a range using comparison operators.
30. Perform a bitwise AND (&) operation on two numbers.
Conditional Statements (10 Questions)
31. Write a program to check if a number is even or odd.
32. Use an if-else statement to print "Good Morning" if the time is less than 12 PM and "Good
Afternoon" otherwise.
33. Write a program to check whether a character is a vowel or consonant.
34. Use a nested if-else statement to find the largest of three numbers.
35. Write a program to check if a year is a leap year using if-else.
36. Use a switch statement to print the day of the week based on a number (1 for Sunday, etc.).
37. Write a program to check if a string is empty or not.
38. Use if statements to categorize age groups (e.g., child, teenager, adult, senior).
39. Write a program to check if a number is divisible by both 3 and 5.
40. Create a program that evaluates a simple grade system (A, B, C) based on marks.
Mixed Questions (10 Questions)
41. Write a program to print the first n natural numbers using a loop and conditional checks.
42. Create a program to calculate the sum of all even numbers in a range.
43. Write code to count how many times a certain letter appears in a string.
44. Write a program that accepts two numbers and an operator (+, -, *, /) and performs the corresponding
operation.
45. Use a conditional statement to check whether a number is prime or not.
46. Write a program to find the largest number in an array using a loop and conditions.
47. Create a program that asks the user for input and checks if it is a valid number.
48. Write a program that calculates the factorial of a given number using a loop and conditions.
49. Write code to simulate a basic login system that checks username and password.
50. Create a program that reverses a string only if it is longer than 5 characters.