How to return object from function?
<p>I am having conceptual Javascript issues while returning Object from functions. Can someone point out what am I doing wrong here?</p>

<pre><code>var productsPartsObj = {
  layers: ['toe', 'base', 'shaft'],
  layer: [
    {
      name: 'toe',
      height: 75,
      width: 78,
      coords: {
        x: 20,
        y: 120
      }
    }
  ]
}

var coords = {};
coords = (function() {
  productsPartsObj.layer.forEach(function(layerObj){
    if ( layerObj.name === "toe" ) {
      return layerObj.coords;
    }
  })
})()

console.log(coords); //logs undefined
</code></pre>
