Really struggling to understand why my conditions are resolving that the array is empty when it isn't!
Here is the code:
const info = [
[
{
"Post": 7
}
]
]
let Result;
if (!Array.isArray(info[0][0]) || info[0][0].length === 0) {
Result = {"Error": "No info"}
}
Even though info has data in it, I still get back Result as {"Error: "No info"}.
Why are my if conditions not working properly? I think its something to do with the !Array.isArray(info[0][0]) part but not sure exactly what.
UPDATE:
If there is no Post then info becomes just this:
const info = [ [ ] ]
Thats why I need to check whether info[0][0] is empty or not
Post!Array.isArray(info[0][0]) === trueimplicitly mean there is something inside yourinfo. You stick to this I thinkresultinstead ofResultin theconsole.log()