I have below array in javascript -
[
{
id:1,
deptName:"Cashier"
},
{
id:2,
deptName:"MF"
},
{
id:3,
deptName:""
},
{
id:4,
deptName:"RD"
},
{
id:5,
deptName:null
},
]
I want to check if any element for deptName in above array is null or empty.
I used -
var isNullOrEmpty= data.every(ele=>(ele.deptName===null || ele.deptName===""))
use of every function is returning false in every case. i.e. whether I keep deptName in any of the element to be null / empty or I fill it with value. With both the cases it is returning me false.
I want to check if any of the deptName in array is null or empty.
.every()returnstruewhen every element in the array fulfills the test. You want.some()-> How much research effort is expected of Stack Overflow users?