MCQ Single Best Answer Difficult

QWhat is the result of the following code in JavaScript?
const str = 'Hello, world!';
console.log(str.substring(7, 12));

ID: #4919 Javascript String MCQ 160 views
Question Info
#4919Q ID
DifficultDifficulty
Javascript String MCQTopic

Choose the Best Option

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

  • A Hello
  • B world
  • C Hello,
  • D world!
Correct Answer: Option B

Explanation

The substring() method returns the characters in a string between two specified indices. In this case, the indices are 7 and 12, so the method returns the characters from index 7 up to but not including the character at index 12, which is 'world'.

Share This Question

Challenge a friend or share with your study group.