JSFiddle - React, Tailwind, and code Playground
by slawe
JavaScript
var myArray = [
{
name: 'lcc',
status: false
},
{
name: 'custid',
status: true
}
];
function objFinder(source) {
var arr = [];
for (var i = 0; i < source.length; i++) {
if (source[i].status === true) {
arr.push(source[i]);
}
}
return arr;
}
//console.log(objFinder(myArray));
if (objFinder(myArray).length !== 0) {
for(var j in objFinder(myArray)) {
console.log(objFinder(myArray)[j].name);
}
} else {
console.log('everthing is OK!');
}