How to remove last character from a string in JavaScript?

To remove last character from a string in JavaScript, do this: string.slice(0, -1).

Here's how you do it:

const string = 'Hello World!';

const noLastChar = string.slice(0, -1);

// Hello World
console.log(noLastChar);