I'm trying to make a validation in js to check if array of objects' properties are empty strings or not, to clarify more, i have an array that has objects inside, and i want to check for each object if it has an empty property (""), here is the code i've written but i'm not sure this is the correct way
const items = [
{ name: "something", quantity: "25", unit: "d" },
{ name: "something", quantity: "25", unit: "d" },
{ name: "something", quantity: "25", unit: "d" },
];
const validation = items.map((item) => {
return Boolean(item.name && item.quantity && item.unit);
});
But it is just giving me an array like this:
[true, true, true]
It is like i want it to only give me the value true if all of the properties are not empty
Thanks
const validation = items.every(i => Object.values(i).every(v => v));