let newData = await tripModel.find(
{ tripId: ID },
{salesOrder:1, no: "$deliveryDetails.invoiceNo", _id: 0 }
);
let nullInvoices = [];
console.log("vvvvvvv", newData[0].salesOrder);
for (let i = 0; i < newData[0].no.length; i++) {
if (newData[0].no[i] === null)
nullInvoices.push({
SO: newData[0].salesOrder[i],
invoice: newData[0].no[i],
});
}`
//error: vvvvvvv { salesOrder: [ 623d917d4c9f21730ace6256, 623da8bbeae48b2f34372a95, 623da8bbeae48b2f34372a92, 623d98964c9f21730ace642c ], no: [ null, '0900009293', '0900009294', null ] } reason TypeError: Cannot read properties of undefined (reading 'length')
I am encountering an issue trying to access the property "no" as it is being returned as undefined.