How to Remove the Last 3 Characters from a String in JavaScript?

Estimated read time 1 min read

To remove the last 3 characters from a string in JavaScript, you can use the slice() method. Here’s an example:

let str = "This is a string";
let newStr = str.slice(0, -3);

This code removes the last 3 characters from the string "This is a string" using the slice() method and logs the modified string: "This is a str".

You May Also Like

More From Author

+ There are no comments

Add yours

Leave a Reply