You can get the last character of a string by decrementing the string length by 1.
The length property gives you the ability to determine the number of elements in an array, or the number of characters in a string.
const dog = "Rottweiler"; const length = dog.length; console.log(length);
To get the last letter or character dynamically, you can do this since the string has an index of “0”:
const lastChar = dog[dog.length - 1]; console.log(lastChar);