title: Create a new object using keys and values from another object
body: <p>I'm saving an object in state that looks like:</p>
  
  <pre><code>ingredients: {
          salad: {
              amount: 3,
              basePrice: 1
          },
          cheese: {
              amount: 2,
              basePrice: 1.2
          }
  }
  </code></pre>
  
  
  
  <p>I want to use this in my component's state as follows</p>
  
  <pre><code>    ingredients: {
      salad: 3,
      cheese: 2
  }
  </code></pre>
  
  <p>I used <code>Object.keys</code> and <code>map</code> at first but it returns an Array of key value pairs instead of objects.</p>
  
  <p>Although this works:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>    const newIngredientsObject = {};
      for (const i in ingredientsObject)
          newIngredientsObject[i] = ingredientsObject[i].amount;
          return newIngredientsObject;</code></pre>
  </div>
  </div>
  </p>
  
  <p>I want to find a solution without a helper method, as such:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="false" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>const mapStateToProps = state =&gt; {
      return {
          ingredients: Object.keys(state.burger.ingredients).map(i =&gt; (
              { [i]: state.burger.ingredients[i].amount } )),
          totalPrice: state.burger.totalPrice
      }
  };</code></pre>
  </div>
  </div>
  </p>