JavaScript Functions – Practice Questions

🔹 Basic Level (1–7)

  1. Create a function that prints "Hello World".
  2. Create a function that takes a name as input and prints:
    👉 "Hello, <name>"
  3. Write a function to add two numbers and return the result.
  4. Create a function to check if a number is even or odd.
  5. Write a function that returns the square of a number.
  6. Create a function that converts Celsius to Fahrenheit.
  7. Write a function that finds the maximum of two numbers.

🔹 Intermediate Level (8–14)

  1. Create a function to calculate the area of a circle.
  2. Write a function that counts the number of vowels in a string.
  3. Create a function that reverses a string.
  4. Write a function that checks if a number is prime.
  5. Create a function that takes an array and returns the sum of all elements.
  6. Write a function that finds the largest number in an array.
  7. Create a function that calculates factorial of a number.

🔹 Advanced Level (15–20)

  1. Convert a normal function into an arrow function.
  2. Write a function with default parameters (e.g., greet user with default name).
  3. Create a function expression that multiplies two numbers.
  4. Write a callback function example:
    👉 One function should accept another function as argument.
  5. Create a function that filters even numbers from an array.
  6. Build a mini calculator using functions:
    👉 add, subtract, multiply, divide

🚀 for students

👉 Combine everything:

  • Take user input
  • Use functions
  • Display result in HTML

Mini project using functions (calculator app)