Noob question. Setting array elements throws an error.
I get this error when I run the script: array1[user_id] is undefined.
array1 = new Array();
// the data variable I got from a JSON source
// using jQuery
$.each(data, function(i, item) {
// Set variables
user_id = item.post.user_id;
user = item.post.user;
price = item.post.price;
if (array1[user_id]['user'] != user) {
array1[user_id]['price'] = price;
array1[user_id]['user'] = user;
}
}
array1[user_id] is undefined?