Single Choice Easy

QWhat is the result of the following code?

var str = "Hello";
var num = 10;
console.log(str + num);

ID: #4886 Javascript Data Types MCQ 176 views
Question Info
#4886Q ID
EasyDifficulty
Javascript Data Types MCQTopic

Choose the Best Option

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

  • A "Hello 10"
  • B "10 Hello"
  • C "10"
  • D "Hello10Hello"
Correct Answer

Explanation

In JavaScript, the + operator can be used to concatenate strings.
In this case, the + operator is used to concatenate the string "Hello" with the number 10
Since one of the operands is a string, the + operator will treat both operands as strings and perform string concatenation.
The result will be the string "Hello10"

Share This Question

Challenge a friend or share with your study group.