Single Choice Easy

QWhat would the following JavaScript code produce?

<p id="demo"></p>
<script>
function myFunction() 
{
   var res = "";
   res = res + Number.isInteger('123');
   document.getElementById("demo").innerHTML = res;
}
</script>

ID: #5025 Javascript Modules MCQ 217 views
Question Info
#5025Q ID
EasyDifficulty
Javascript Modules MCQTopic

Choose the Best Option

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

  • A true
  • B false
  • C error
  • D undefined
Correct Answer

Explanation

This script defines a function called myFunction() that does the following:
Declares a variable res and initializes it to an empty string.
Concatenates the result of the Number.isInteger() function applied to the string '123' to res.
The Number.isInteger() function returns a boolean value indicating whether the value passed to it is an integer.
In this case, it would return false because the value passed is a string, not a number.

Selects the element with the ID "demo" and changes its inner HTML to the value of res. When the function is called, the element with the ID "demo" would display the text "false".

Share This Question

Challenge a friend or share with your study group.