title: IndexOf(elem) is always returning -1 even when element is included
body: <p>I am trying to loop through a list in the format below (origPlan) and count the quantity of each item in the list and then translate that into a final result which will look like this: </p>
  
  <pre><code>finalPlan =[{"first":2},{"second":2}]
  </code></pre>
  
  <p>My logic is below however in my if statement it is always returning -1 and I am executing my else statement each time, what am I missing? Is there an alternative to the indexOf function that would return -1 if the element is not included? I think I may not be accessing the items in finalPlan properly but I am unsure how to proceed.</p>
  
  <pre><code>var origPlan = {"first","second","first","second"}
  var finalPlan = [];
  
  //loop through each element of my array 
  for(var i =0; i&lt;origPlan.length; i++){
  
    //check to see if the element has been added to my new array already
    if(finalPlan.indexOf(origPlan[i]) == -1){
  
    //if not, lets add it here with quantity of 1 
     finalPlan.push({
        variantId: origPlan[i],
        quantity: 1
       });
    }
  
    //other wise I will increase quantity here: logic not included for simplicity
    else{console.log("duplicated");}
  }
  </code></pre>