function(data) {
var lob = new LOBslist(); //new object
var returnLOB = []; //array init
for (var i1r= 0; i1r < data.length; i1r++) {
var cLob = data[i1r];
lob.name = cLob.name;
lob.id = cLob.id;
returnLOB.push(lob); //adding to array?
console.log(lob); //right here
}
console.log(returnLOB);
return returnLOB;
}
data is in a format like
{"name":"RYI","id":2,"name":"BIB","id":1}
I want to access the above data, store each name and id in an object called lob and store each object in an array returnLOB.
Every time I loop through and console.log(lob), I get correct objects like: RYI id:2 and BIB id:1 then
but when I try to store them in the returnLOB array it outputs the second object twice rather than each object once.
Any idea what is wrong here?