I have an array of objects which are phone numbers such as:
phoneArray = [{"phone": "+11 111 111"},{"phone": "+22 222 222"}]
I did a loop on it to remove spaces because I want this result:
[{"phone": "+11111111"},{"phone": "+22222222"}]
but I only could remove the first space which looked like
[{"phone": "+11111 111"},{"phone": "+22222 222"}
with this code:
for(i=0 ; i<phoneArray.length ; i++) {
let test = phoneArray[i].phone.replace(" ","");
}
I actually have other phone numbers like {"phone": "(22) 222-222"} to format but if I can remove space I can remove other signes like ()- I think.
I don't use regex because I don't understand it yet.