Get the last N characters of a String in JavaScript | bobbyhadz
bobbyhadz.com · Nov 17, 2022
To get the last N characters of a string, call the `slice` method on the string, passing in `-n` as a parameter, e.g. `str.slice(-3)` returns a new string containing the last 3 characters of the original string.