Single Choice Difficult

QWhat is the result of the following code in JavaScript?
const str = 'Hello, world!';
console.log(str.charAt(str.length - 1));

ID: #4917 Javascript String MCQ 201 views
Question Info
#4917Q ID
DifficultDifficulty
Javascript String MCQTopic

Choose the Best Option

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

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

Explanation

The charAt() method returns the character at a specified index in a string.
In this case, the index is the length of the string minus 1, which is the last character of the string, '!'.

Share This Question

Challenge a friend or share with your study group.