title: Javascript. Object.values(...).reduce
body: <p>Can anyone explain in detail how this piece of code works?</p>
  <pre><code>const yourAmazingFunction = (salaries) =&gt; Object.values(salaries).reduce((acc, el) =&gt; acc + el, 0);
  </code></pre>
  <p>specifically this:</p>
  <pre><code>((acc, el) =&gt; acc + el, 0);
  </code></pre>
  <p>Here's all the code:</p>
  <pre><code>const nonEmptySalaries = {
   John: 100,
   Ann: 160,
   Pete: 130
  };
  
  const emptySalaries = {};
  
  const yourAmazingFunction = (salaries) =&gt; Object.values(salaries).reduce((acc, el) =&gt; acc + el, 0);
  
  const firstResult = yourAmazingFunction(nonEmptySalaries)
  
  const secondResult = yourAmazingFunction(emptySalaries)
  
  console.log(firstResult); // 390
  console.log(secondResult); // 0 ```
  
  </code></pre>