Basic JavaScript (35/111) | Use Bracket Notation to Find the Nth to Last Character in a String | freeCodeCamp
Full playlist 👉 • Basic JavaScript (1/111) | Comment Yo...
You can use the same principle we just used to retrieve the last character in a string to retrieve the Nth-to-last character.
For example, you can get the value of the third-to-last letter of the var firstName = "Charles" string by using firstName[firstName.length - 3]
Example:
var firstName = "Charles";
var thirdToLastLetter = firstName[firstName.length - 3]; // thirdToLastLetter is "l"
Watch video Basic JavaScript (35/111) | Use Bracket Notation to Find the Nth to Last Character in a String online, duration hours minute second in high quality that is uploaded to the channel Stral Tech 14 August 2020. Share the link to the video on social media so that your subscribers and friends will also watch this video. This video clip has been viewed 290 times and liked it 4 visitors.