title: Jquery grep then change value of objects in array
body: <p>I want to be able to filter through an array of objects such as </p>
  
  <pre><code>object {
     temperature: 1;
     humidity: 2;
     precipitation: 3;
  }
  </code></pre>
  
  <p>Originally I was doing a for each loop and then pushing onto a new array like so: </p>
  
  <pre><code>let array1 = [];
  $.each(data(a,b) {
      if (condition a &amp;&amp; condition b) {
          array1.push(id: b, text: b.temperature);
      }
   });
  </code></pre>
  
  <p>I have tried to use grep to do something like </p>
  
  <pre><code>let array1 = $.grep(data, function(a) {
      return condition a &amp;&amp; condition b
  });
  </code></pre>
  
  <p>This works on filtering the array but is there a good way to change the values of the objects inside of the grep statement like I had before? I tried to do something like </p>
  
  <pre><code>if(condition a &amp;&amp; condition b){
      return(id: a, text: b.temperature)
  }
  </code></pre>
  
  <p>But whenever I do things like this the thing that is returned is just the original object that was in data. It seems that trying to modify the data and returning that as the filtered object does not work. Is there an elegant way of doing this that doesn't result into essentially the same code I had as before? </p>