Use Bracket Notation to Find the Last Character in a String, freeCodeCamp Basic Javascript

Lesson Summary

In this challenge we continue exploring bracket notation and learn a handy trick to target the last character of a string. Subtracting 1 from the length of a string variable and setting the result inside bracket notations will target that lest character. For example to target the last character of a string var myCode = "code", you can target the "e" character like this myCode[myCode.length - 1]

Subscribe To Monthly Newsletter. Chance to Win Monthly Prizes

* indicates required