MCQ Single Best Answer Easy

QWhat is the result of the following code?
var str = "Hello World!";
console.log(str.startsWith("Hello"));

ID: #4900 JavaScript Operator MCQ 197 views
Question Info
#4900Q ID
EasyDifficulty
JavaScript Operator MCQTopic

Choose the Best Option

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

  • A true
  • B false
  • C "false"
  • D "true"
Correct Answer: Option A

Explanation

The startsWith method in JavaScript is a method that can be called on a string value to determine whether the string starts with the specified string.
In this case, the startsWith method is called on the string "Hello World!", with the string "Hello" as the argument.
Since the string "Hello World!" does start with the string "Hello", the startsWith method will return true.

Share This Question

Challenge a friend or share with your study group.