Answers for "javascript remove a space for each character"

5

javascript remove spaces at the beginning of the end of the string

const stringWithSpaces = '   I learn JS with Coderslang every day   ';

console.log(stringWithSpaces.trimStart());  //'I learn JS with Coderslang every day   '
console.log(stringWithSpaces.trimEnd());    //'   I learn JS with Coderslang every day'
console.log(stringWithSpaces.trim());       //'I learn JS with Coderslang every day'
Posted by: Guest on February-03-2021
4

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
Posted by: Guest on June-02-2021

Code answers related to "javascript remove a space for each character"

Code answers related to "Javascript"

Browse Popular Code Answers by Language