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

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
0

remove whitespace with regex javascript

return str.replace(/\s/g, '');
Posted by: Guest on November-29-2020
10

js remove space before string

var str = "  Some text ";
str.trim();
// str = "Some text"
Posted by: Guest on May-27-2020
46

javascript trim

var str=" I have outer spaces ";
var cleanStr=str.trim();//trim() returns string with outer spaces removed
Posted by: Guest on June-27-2019
0

javascript remove first space in string

//use trim() on your string. It removes first and last whitepsaces

let str = " aa bb    ";
console.log(str.trim()); // "aa bb"
Posted by: Guest on August-20-2020

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

Code answers related to "Javascript"

Browse Popular Code Answers by Language