Answers for "remove spaces from beginning and end of string javascript"

22

remove spaces in a string js

str.replace(/\s+/g, '')
Posted by: Guest on April-29-2020
3

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
2

javascript remove all spaces from string

str = str.replace(/\s/g, '');
Posted by: Guest on July-22-2020
18

javascript remove all whitespaces

var spacesString= "Do I have spaces?"; 
var noSpacesString= myString.replace(/ /g,'');// "DoIhavespaces?"
Posted by: Guest on August-01-2019
6

remove space from string javascript

var str = "       Hello World!        ";
alert(str.trim());
Posted by: Guest on March-19-2020

Code answers related to "remove spaces from beginning and end of string javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language