Answers for "js how to remove one space from beging of string"

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
3

remove extra space in string js

newString = string.replace(/\s+/g,' ').trim();
Posted by: Guest on May-28-2020

Code answers related to "js how to remove one space from beging of string"

Code answers related to "Javascript"

Browse Popular Code Answers by Language