put values back to corresponding users in array
<p>From the following sample of code am trying to get the location from text while looping through each of the users of the text_array. After extracting the location from the text I am trying to put the values back to the array where the it corresponds to the right user but it gives me the error  "text_array[i] is undefined". What am I doing wrong with this one ?</p>

<pre><code>function replace_undefined(text_array) {
    var userLocationText = {};
    for (i = 0, l = text_array.length; i &lt; l; i++) {
        console.log(text_array[i].user);
        userLocationText[text_array[i].user] = text_array[i].location;
        var text = text_array[i].text;
        Placemaker.getPlaces(text, function (o) {
            console.log(o);
            if ($.isArray(o.match)) {
                if (o.match[0].place.name == "Europe" || o.match[0].place.name == "United States") {
                    var location = o.match[1].place.name;
                    userLocationText[text_array[i].user] = location;
                }
                if ($.isArray(o.match)) {
                    if (o.match[0].place.name !== "Europe") {
                        var location = o.match[0].place.name;
                        userLocationText[text_array[i].user] = location;
                    }
                }
            } else if (!$.isArray(o.match)) {
                var location = o.match.place.name;
                userLocationText[text_array[i].user] = location;
            }

            console.log(text_array);
        });
    }
}

}

text_array = [{
    user: a,
    user_id: b,
    date: c,
    profile_img: d,
    text: e,
    contentString: f,
    url: g,
    location: undefined
}, {
    user: a,
    user_id: b,
    date: c,
    profile_img: d,
    text: e,
    contentString: f,
    url: g,
    location: undefined
}, {
    user: a,
    user_id: b,
    date: c,
    profile_img: d,
    text: e,
    contentString: f,
    url: g,
    location: undefined
}];
</code></pre>
