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

Опубликовано: 11 Март 2017
на канале: We Will Code
2,383
12

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]