const str = 'Hello, world!'; console.log(str.charAt(str.length - 1));
The charAt() method returns the character at a specified index in a string.
In this case, the index is the length of the string minus 1, which is the last character of the string, '!'.