I have array what looks like this:
var arr = [{name: 'Test', id: 1}, {name: 'Test', id: 2}, {name: 'Test', id: 3}];
When I looping through this array I want to prepare new array:
var new_arr = [];
for (var key in arr) {
if (arr[key].name == 'Test') {
new_arr.push(arr[key]);
}
}
But when I Logger.log(new_arr)
it looks:
[{name: 'Test': id: 3}]
So the questions is: What is wrong with this code!? When I log each item all fine, but it looks like it push only last element. Thanks!
P.S. I tested this code on local machine and all works fine!