how to replace first and last character of string in javascript

JavaScript
const removeChar = (str) => str.slice(1, -1);
Source

Also in JavaScript: