Cómo eliminar el espacio de arrastre en la cadena JS

let string = "        Your Text           ";
string = string.trim(); // "Your Text"
// This gets rid of both starting and trailing whitespace
Eatable Chocolate