I have the following code
var ola = "242 052";
How do I remove space from the variable? To make it look like this:
var ola = "242052";
Thank you
I have the following code
var ola = "242 052";
How do I remove space from the variable? To make it look like this:
var ola = "242052";
Thank you
For a space:
var ola = "242 052";
ola = ola.replace(" ","")
console.log(ola);
More than one space:
var ola = "242 052";
ola = ola.replace( /\s/g, '' )
console.log(ola);
The global Match g
- searches for all occurrences of the expression in the text, rather than stopping at the first occurrence.
var ola = "242 052 098 09 8 7";
ola = ola.replace( / /g, '' )
console.log(ola);
var ola = '123 456 789';
ola = ola.split(' ').join('');
console.log(ola);