How do you read the first character in a string ?
-
stringName.charAt(0);
-
stringName.substring(1);
-
stringName.charAt(1);
-
stringName.charAt(2);
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.