Multiple choice technology web technology

How do you read the first character in a string ?

  1. stringName.charAt(0);

  2. stringName.substring(1);

  3. stringName.charAt(1);

  4. stringName.charAt(2);

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

JavaScript strings are zero-indexed, meaning the first character is at position 0. The charAt() method returns the character at a specified index. To get the first character, use charAt(0). substring(1) would return from position 1 to the end.