FBISE, NCP & NBF-aligned resources for Classes 9–12
Browse by Class
Browse by Type
Computer Chapter 3 : Topic 3.2
Variable assignment in JavaScript
1 / 15
A student creates a variable and assigns the value 20 to it for storing a user's age on a webpage. What is this process called?
Reasoning: Assigning a value to a variable is known as variable assignment.
2 / 15
Consider the statement let score = 50; used in a JavaScript program. Which part of the statement assigns the value to the variable?
Reasoning: The assignment operator (=) assigns a value to a variable.
3 / 15
A programmer wants to store the value "Ali" in a variable named studentName. Which statement correctly performs this assignment?
Reasoning: The assignment operator = stores the value in the variable.
4 / 15
A variable named marks already contains the value 60. What will be the new value after executing marks = 80;?
Reasoning: Assignment replaces the previous value with the new one.
5 / 15
A programmer writes let x = 5; let y = x;. What value will be stored in y?
Reasoning: The value stored in x is copied to y.
6 / 15
A student wants to update the value of a variable during program execution. Which JavaScript feature allows this?
Reasoning: Reassignment changes the value stored in a variable.
7 / 15
Consider the code: let price = 100; price = 120; What value will price contain after execution?
Reasoning: The second assignment replaces the original value.
8 / 15
A student writes let total = 15 + 10;. What value is assigned to total?
Reasoning: JavaScript evaluates the expression before assignment.
9 / 15
Which statement correctly assigns the Boolean value true to a variable named isLoggedIn?
Reasoning: Boolean values are assigned without quotation marks.
10 / 15
A programmer assigns city = "Lahore"; and later executes city = "Karachi";. What happens?
Reasoning: Reassignment updates the variable with the new value.
11 / 15
A student creates the statement let num = 7; num = num + 3;. What is the final value of num?
Reasoning: num + 3 becomes 7 + 3, resulting in 10.
12 / 15
Which of the following statements assigns the value stored in variable a to variable b?
Reasoning: The value on the right side is assigned to the variable on the left.
13 / 15
A web application stores the number of visitors in a variable. Why is reassignment useful in this situation?
Reasoning: Reassignment allows the stored value to change as visitors increase.
14 / 15
What will be the value of result after executing the following code? let result = 12; result = result * 2;
Reasoning: 12 2 = 24, which is assigned back to result.
15 / 15
A programmer assigns different types of values to the same variable at different times. Which statement best describes JavaScript behavior?
Reasoning: JavaScript is dynamically typed, so a variable can hold different types of values during execution.
Your score is
Restart quiz