Answers for "filter last object of recursive array using javascript"

0

filter last object of recursive array using javascript

function find(obj, key) {
  if (obj.value && obj.value.indexOf(key) > -1){
    return true;
  }
  if (obj.children && obj.children.length > 0){
    return obj.children.reduce(function(obj1, obj2){
      return find(obj1, key) || find(obj2, key);
    }, {}); 
  } 
  return false;
}

var output = input.filter(function(obj){
     return find(obj, 'Hit');
 });
console.log('Result', output);
Posted by: Guest on October-14-2021

Code answers related to "filter last object of recursive array using javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language