title: Javascript object recursion to find an item at the deepest level
body: <p>I'm trying to recursively search an object that contains strings, arrays, and other objects to find an item (match a value) at the deepest level however I'm always getting undefined as the return result.  I can see through some console logging that I am finding the item but it gets overwritten.  Any idea where I'm going wrong?</p>
  
  <pre><code>  var theCobWeb = {
      biggestWeb: {
        item: "comb",
        biggerWeb: {
          items: ["glasses", "paperclip", "bubblegum"],
          smallerWeb: {
            item: "toothbrush",
            tinyWeb: {
              items: ["toenails", "lint", "wrapper", "homework"]
            }
          }
        },
        otherBigWeb: {
          item: "headphones"
        }
      }
    };
  
    function findItem (item, obj) {
    var foundItem;
    for (var key in obj) {
      if (obj[key] === item) {
        foundItem = obj;
      } else if (Array.isArray(obj[key]) &amp;&amp; obj[key].includes(item)) {
        foundItem = obj;
      } else if (typeof obj[key] === 'object' &amp;&amp; !Array.isArray(obj[key])) {
        findItem(item, obj[key]);
      } 
    }
        return foundItem;
  }
  
  var foundIt = findItem('glasses', theCobWeb);
  console.log('The item is here: ' + foundIt); // The item is here: undefined 
  </code></pre>
  
  <p>Edit: cleaned up the code a bit based on feedback below.  </p>