title: Find last matching object in array of objects
body: <p>I have an array of objects. I need to get the object type ("shape" in this example) of the last object, remove it, and then find the index of the previous object in the array that has the same type, e.g. "shape".</p>
  
  <pre><code>var fruits = [
      { 
          shape: round,
          name: orange
      },
      { 
          shape: round,
          name: apple
      },
      { 
          shape: oblong,
          name: zucchini
      },
      { 
          shape: oblong,
          name: banana
      },
      { 
          shape: round,
          name: grapefruit
      }
  ]
  
  // What's the shape of the last fruit
  var currentShape =  fruits[fruits.length-1].shape;
  
  // Remove last fruit
  fruits.pop(); // grapefruit removed
  
  // Find the index of the last round fruit
  var previousInShapeType = fruits.lastIndexOf(currentShape);
      // should find apple, index = 1
  </code></pre>
  
  <p>So, obviously the type in this example will be "round". But I'm not looking for an array value of "round". I'm looking for where fruits.shape = round.</p>
  
  <pre><code>var previousInShapeType = fruits.lastIndexOf(fruits.shape = currentShape);
  </code></pre>
  
  <p>But just using that doesn't work. I'm sure I'm missing something simple. How do I find the last item in the array where the shape of the object = round?  </p>