I do not understand this one.
invoiceList shows one record.
LENGTH: shows 1
But it still triggers if (!invoiceList.length) {
show({invoiceList})
show("LENGTH: " + invoiceList.length)
if (!invoiceList.length) {
reject({code:"MULTI INVOICE ERROR", err:"You need to make an invoice"});
return;
}
How come that !invoiceList.length is triggered when length is 1?
I just tried this:
var invoiceList = [
{
"foo": "bar",
},
{
"foo": "bar",
},
{
"foo": "bar",
}
]
console.log(invoiceList)
console.log("LENGTH: " + invoiceList.length)
console.log("LENGTH: " + invoiceList.length)
if (!invoiceList.length) {
reject({code:"ERR 1", err:"You need to make an invoice"});
}
if (invoiceList.length<1) {
reject({code:"ERR 2", err:"You need to make an invoice"});
}
if (!invoiceList.length) {
reject({code:"MULTI INVOICE ERROR", err:"You need to make an invoice"});
}
return;
And console.log gives me the following:
[ { foo: 'bar' }, { foo: 'bar' }, { foo: 'bar' } ]
LENGTH: 3
LENGTH: 3
{ code: 'MULTI INVOICE ERROR',
err: 'You need to make an invoice with the word PRICE in one of the lines' }
getInvoice: [object Object]
So now I am really confused?!?!