MCQ Practice Single Best Answer Topic: Javascript String MCQ

Q What is the result of the following code in JavaScript?
const str = 'Hello, world!';
console.log(str.charAt(0));

Question ID
#4916
Subchapter
Javascript String MCQ
Action
Choose one option below

Choose Your Answer

Click an option to check whether your answer is correct.

  • A H
  • B e
  • C l
  • D !
Correct Answer: A

Explanation

The charAt() method returns the character at a specified index in a string.
In this case, the index is 0, so the method returns the first character of the string, which is 'H'.

Share This Question

Share this MCQ with your friends or study group.