title: Pass object key name argument into function
body: <p>I have the following function which takes a dataset, field name and search string then uses ES2015's arrow functions to find the result.</p>
  
  <p>Example call is:</p>
  
  <pre><code>var whatever = myDataSet.find(entry =&gt; entry.name === 'John');
  </code></pre>
  
  <p>I need to build this from arguments within a function but I cannot get the field name in. </p>
  
  <p>The function:</p>
  
  <pre><code>findSingle: function(dataSet, fieldName, searchString){
      return dataSet.find(entry =&gt; entry.fieldName === searchString);
  }
  </code></pre>
  
  <p>Which I'd call with:</p>
  
  <pre><code>my.nameSpace.findSingle(dataSetName, 'name', 'John');
  </code></pre>
  
  <p>And I expect it to then call:</p>
  
  <pre><code>dataSetName.find(entry =&gt; entry.name=== 'john');
  </code></pre>
  
  <p>But it fails. (If I hard code <code>entry.name</code> it work as expected) I'm pretty sure it's because I'm passing a string to be an object property for <code>entry.name</code> but I can't think of another way to do this.</p>
  
  <p>Is it possible to pass strings into object properties like this or should I do it a different way?</p>