title: Check if object value exists within a Javascript array of objects and if not add a new object to array
body: <p>If I have the following array of objects:</p>
  
  <pre><code>[ { id: 1, username: 'fred' }, { id: 2, username: 'bill' }, { id: 2, username: 'ted' } ]
  </code></pre>
  
  <p>Is there a way to loop through the array to check whether a particular username value already exists and if it does do nothing, but if it doesn't to add a new object to the array with said username (and new ID)?</p>
  
  <p>Thanks!</p>