//Масив
const array = [
{
name: 'test2',
id: 123,
lastName: '123he'
},
{
name: null,
id: 13,
lastName: 'world'
},
{
name: 'hello',
id: 12,
lastName: '13h43'
},
{
name: 'text',
id: 23,
lastName: null
}
];
var length = array.length;
var i = 1;
while (i<length){
if(array[i].name == null){
if(array[i].lastName == null){
array[i].name = array[i].name;
} else {
array[i].name = array[i].lastName;
}
}
i++;
}