In the below array, how can I remove whitespace between words within each string? I want to convert "FLAT RATE" to "FLATRATE" and "FREE SHIPPING" to "FREESHIPPING".

I had to work out with array. I saw the solutions for simple string's case.
You can use array.map function to loop in array and use regex to remove all space:
var array = ['FLAT RATE', 'FREE SHIPPING'];
var nospace_array = array.map(function(item){
return item.replace(/\s+/g,'');
})
console.log(nospace_array)
a string can be split and joined this way:
s.split(" ").join("");
That removes spaces.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With