Created
May 22, 2022 19:42
-
-
Save devded/d1715a425b679744addb231d6f2dd119 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data = [ | |
{ | |
id: 1, | |
name: null, | |
price: 1, | |
}, | |
{ | |
id: "2", | |
name: "Nike", | |
price: "", | |
}, | |
]; | |
// check data array object is not empty | |
for (var i = 0; i < data.length; i++) { | |
console.log(data[i]); | |
const isEmpty = Object.values(data[i]).some((x) => x === null || x === ""); | |
console.log(isEmpty); | |
console.log("Object key cannot be empty or null"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment