In my application i need to get some data from JSON and convert it to an array for further use.
And I have my codes to get and convert the data:
var Persons = data.Persons;
var PersonsArr = [];
for (var i=0; i < Persons.length; i++){
PersonsArr.push(Persons[i].word);
}
This is quite simple, i just call the api and use a single for loop to get everything. The out come is like
PersonsArr=["peter","mary","tom"];
Then i append it to an element but it has "," to split each of the data and i'd like to remove it.
So i tried to use .replace()
for (var i=0; i < Persons.length; i++){
PersonsArr.push(Persons[i].word.replace(",", " "));
}
But it's not working as my exceptation, am i using the wrong apporch?