You use the square brackets [] at the end of the variable to isolate the specific letter. letter. Because JavaScript uses 0-based indexing, that means the first letter has index 0 and the last letter of a string has index string.length - 1.
Edit the solution out by moderator.
Hey Ramanuj, let me break your problem into steps.
1)
You need to find the last character in the string for example -“Ramanuj” string contains 7 characters and the last character is “j”.
2)
string and arrays are index or numbered starting with 0 so in string “Ramanuj” character “R” is at index 0 and the last character “j” is at 6 index and not 7 as index start from zero and not one.
3)
To access any character in string or element of an array we use bracket notation.
var str = “Ramanuj”;
var firstCharacter = str[0] ;
console.log(firstCharacter) // “R”;
4)
to find the length of an array or string we use length property.
var str = “Ramanuj”;
var len = str.length;
console.log(len) // 6 as index start from 0.