JavaScript MCQ Javascript Data Types MCQ Question #4885
Single Choice Easy

QWhat is the result of the following code?
var num = 10;
num++;
console.log(num);

ID: #4885 Javascript Data Types MCQ 263 views
Question Info
#4885Q ID
EasyDifficulty
Javascript Data Types MCQTopic

Choose the Best Option

Click any option to instantly check if you're correct.

  • A 10
  • B 11
  • C "10"
  • D "11"
Correct Answer

Explanation

The ++ operator in JavaScript is an increment operator, which increments a number by 1.
In this case, the variable num is initially assigned the value 10, which is a number.
On the second line, num is incremented by 1 using the ++ operator.
Therefore, num now has a value of 11, and when it is logged to the console, the value 11 will be displayed.

Share This Question

Challenge a friend or share with your study group.