When I run this in my console:
var test = "A-Test (One Two 3)"
test.toLowerCase().replace(" ", "").replace("-", "");
The output is:
atest(one two 3)
Why aren't the spaces inside the parenthesis being replaced?
How can I strip all spaces?
When I run this in my console:
var test = "A-Test (One Two 3)"
test.toLowerCase().replace(" ", "").replace("-", "");
The output is:
atest(one two 3)
Why aren't the spaces inside the parenthesis being replaced?
How can I strip all spaces?
 
    
    To replace mulitple instances of a pattern, with String.replace() you have to use a regular expression, rather than a string, to identify the specific instance(s) to be replaced, along with the g modifier:
var test = "A-Test (One Two 3)"
test.toLowerCase().replace(/ /g, "").replace("-", "");
var test = "A-Test (One Two 3)",
  modifiedTest = test.toLowerCase().replace(/ /g, "").replace("-", "");
console.log(modifiedTest);