Site icon Hello Newz

CBSE Sample Paper 2025: 50 Important Questions & Answers from Class 12 Web Application Chapter – JavaScript (Part 2)

CBSE Sample Paper 2025

CBSE Sample Paper 2025

Get ready for CBSE Sample Paper 2025 with these 50 important questions and answers from Class 12 Web Application Chapter – JavaScript (Part 2). Based strictly on the latest syllabus, this guide helps you score high in your board exams.

Chapter 2: JavaScript (Part 2) – 50 Important Questions and Answers

1 Mark Questions (Very Short Answer)

  1. What is JavaScript?
    Answer: JavaScript is a lightweight scripting language used to make web pages interactive.
  2. How is JavaScript different from Java?
    Answer: JavaScript is for client-side scripting; Java is a general-purpose programming language.
  3. What is a variable in JavaScript?
    Answer: A variable stores data values. Example: var x = 10;
  4. Name three JavaScript data types.
    Answer: Number, String, Boolean.
  5. What is the output of typeof(42)?
    Answer: ‘number’
  6. What is the use of the return statement?
    Answer: It returns a value from a function.
  7. What are arrays in JavaScript?
    Answer: Arrays store multiple values in one variable. Example: var arr = [1, 2, 3];
  8. What is the use of loops in JavaScript?
    Answer: To repeat a block of code multiple times.
  9. What symbol is used for comments in JavaScript?
    Answer: // for single-line, /* */ for multi-line.
  10. How do you terminate a statement in JavaScript?
    Answer: With a semicolon ;.

CBSE Sample Paper 2025: 2 Mark Questions

  1. Write a program to add two numbers.

Answer: var a = 5, b = 3;

var sum = a + b;

console.log(sum);

  1. Define function with syntax.
    Answer: A function performs a task.

function name() {

/* code */

}

  1. What are global and local variables?
    Answer: Global: accessible everywhere. Local: only within a function.
  2. Name types of loops in JavaScript.
    Answer: for, while, and do-while.
  3. Write syntax of a for loop.

Answer: for(initial; condition; increment) { /* code */ }

  1. How to access second element of array arr?
    Answer: arr[1]
  2. How do you find length of a string?
    Answer: “Hello”.length returns 5.
  3. What is the difference between == and ===?
    Answer: == compares values, === compares value and type.
  4. What is typeof operator used for?
    Answer: To get the type of a variable.
  5. Name any two arithmetic operators.
    Answer: + (Addition), – (Subtraction)

CBSE Sample Paper 2025: 3 Mark Questions

  1. Write a function to calculate square of a number.

Answer: function square(n) {

  return n * n;

}

  1. Write a program to print all elements of an array.

Answer: var arr = [1, 2, 3];

for(var i = 0; i < arr.length; i++) {

  console.log(arr[i]);

}

  1. Difference between while and do-while loop.
  1. Write a program using while loop to print numbers 1 to 3.

Answer: var i = 1;

while(i <= 3) {

  console.log(i);

  i++;

}

  1. Write syntax of do-while loop.

Answer: do {

  // code

} while (condition);

  1. What is an object in JavaScript?
    Answer: A collection of key-value pairs.
    Example: { name: “John”, age: 20 }
  2. Write code to create a student object.

Answer: var student = { name: “Aman”, age: 17 };

  1. How to access object property name?
    Answer: student.name or student[“name”]
  2. Write a function to reverse a string.

Answer: function reverse(str) {

  return str.split(”).reverse().join(”);

}

  1. Write a function to convert Celsius to Fahrenheit.

Answer: function convert(c) {

  return (c * 9/5) + 32;

}

CBSE Sample Paper 2025: 5 Mark Questions

  1. Write a function to find factorial of a number.

Answer: function factorial(n) {

  let f = 1;

  for(let i = 1; i <= n; i++) {

    f *= i;

  }

  return f;

}

  1. Write a function to check if a number is even or odd.

Answer: function check(num) {

  if(num % 2 == 0)

    return “Even”;

  else

    return “Odd”;

}

  1. Write a function to find max of three numbers.

Answer: function max(a, b, c) {

  return Math.max(a, b, c);

}

  1. Write a function to count vowels in a string.

Answer: function countVowels(str) {

  return str.match(/[aeiou]/gi).length;

}

  1. Write a program to print numbers from 1 to 10 using for loop.

Answer: for(let i = 1; i <= 10; i++) {

  console.log(i);

}

  1. Write a function to sum elements of an array.

Answer: function sumArray(arr) {

  let sum = 0;

  for(let i of arr) {

    sum += i;

  }

  return sum;

}

  1. Write a function to check if a number is prime.

Answer: function isPrime(n) {

  if(n < 2) return false;

  for(let i = 2; i < n; i++) {

    if(n % i == 0) return false;

  }

  return true;

}

  1. Difference between var, let, and const.
  1. What is hoisting in JavaScript?
    Answer: Variable and function declarations are moved to the top of their scope before execution.
  2. Write a program using break to exit a loop.

Answer: for(let i = 1; i <= 10; i++) {

  if(i === 5) break;

  console.log(i);

}

  1. What is null and undefined?
  1. What is DOM?
    Answer: DOM (Document Object Model) allows JavaScript to interact with HTML.
  2. Write syntax to write a comment in JavaScript.
    Answer: // This is a comment
    /* Multi-line comment */
  3. What is the difference between parseInt() and parseFloat()?
    Answer: parseInt() returns integer part, parseFloat() returns floating point.
  4. How to convert string “123” to a number?
    Answer: Using Number(“123”) or parseInt(“123”).
  5. What is scope?
    Answer: The context where variables are accessible — local or global.
  6. How to write an arrow function in JavaScript?

Answer: const add = (a, b) => a + b;

  1. What are control statements?
    Answer: Statements that control the flow of execution — like if, switch, loops.
  2. Explain continue statement with example.
    Answer: Skips the current iteration.

for(let i=1; i<=5; i++) {

  if(i == 3) continue;

  console.log(i);

}

  1. Write a JavaScript program to print a multiplication table of 5.

Answer:

for(let i = 1; i <= 10; i++) {

  console.log(“5 x ” + i + ” = ” + (5 * i));

}

Also Read: CBSE Web Application class 12 sample paper: Emerging Trends

Exit mobile version