0
I have an array:
let arr = ['Feijao, Arroz', 'Melancia', 'Banana', 'Laranja,Uva']
and would like her to become:
let arr = ['Feijao, Arroz', 'Melancia', 'Banana', 'Laranja, Uva']//(consertando o erro de vírgula).
I wrote the code
let arr = ['Feijao, Arroz', 'Melancia', 'Banana', 'Laranja,Uva']
for(let i = 0; i < arr.length; i++){
let search = arr[i].search(/,\w/g)
if(search >= 0){
arr[i][search] += ' '
}
console.log(search);
}
console.log(arr)
But it doesn’t change anything at all. I’ve tried charAt, but I can’t formulate the right logic..
(the values together within the string are purposeful: ['A, B', 'C', ’D,E'])
Are you sure that the example you gave is the result you would like and not that it was
['Feijao, Arroz', 'Melancia', 'Banana', 'Laranja', 'Uva']
?– Sorack
Absolute. Some values would be grouped in a single string: 'Bean, Rice' , 'Orange, Grape'
– retr0