- A 30
- B "30"
- C "1020"
- D TypeError
- Share this MCQ
Answer:
C
Share this MCQ
In JavaScript, the +
operator can be used to add numbers or concatenate strings.
If both operands are numbers, the +
operator will perform addition.
If either operand is a string, the +
operator will treat both operands as strings and perform string concatenation.
In this case, the first operand (num1)
is a number, but the second operand (num2)
is a string.
Therefore, the +
operator will treat both operands as strings and perform string concatenation, resulting in the string "1020"
.
Share this MCQ