js remove trailing whitespace code example
Example 1: how to remove trailing space in string js
let string = " Your Text ";
string = string.trim(); // "Your Text"
// This gets rid of both starting and trailing whitespace
Example 2: remove whitespace javascript
var str = " Some text ";
str.trim();