title: Cannot figure out how to use "for ... in" in JavaScript
body: <p>The following code expects that all the properties of this.triggeredTests are arrays and calculates their total length:</p>
  
  <pre><code>    let savedLen = 0;
  
      const values = Object.values(this.triggeredTests);
  
      for (let i = 0; i &lt; values.length; i += 1) {
        savedLen += values[i].length;
      }
  </code></pre>
  
  <p>if I try to rewrite this code with <strong>for ... in</strong>:</p>
  
  <pre><code>    for (const val in values) {
        savedLen += val.length;
      }
  </code></pre>
  
  <p>I got some annoying errors:</p>
  
  <pre><code>  ✘  http://eslint.org/docs/rules/guard-for-in          The body of a for-in should be wrapped in an if statement to filter unwanted properties from the prototype
    src\components\entity\Test.vue:171:9
            for (const val in values) {
            ^
  
    ✘  http://eslint.org/docs/rules/no-restricted-syntax  for..in loops iterate over the entire prototype chain, which is virtually never what you want. Use Object.{keys,values,entries}, and iterate over the resulting array
    src\components\entity\Test.vue:171:9
            for (const val in values) {
            ^
  
  
  ✘ 2 problems (2 errors, 0 warnings)
  
  
  Errors:
    1  http://eslint.org/docs/rules/no-restricted-syntax
    1  http://eslint.org/docs/rules/guard-for-in
  </code></pre>
  
  <p>Is it possible to make this <strong>for ... in</strong> work?</p>
  
  <p>I am to sure what compiler I use, but at least I know that I am working in Node.js v8.12.0 environment with NPM.</p>
  
  <p><strong>EDIT1:</strong></p>
  
  <p>If I use <strong>for ... of</strong>:</p>
  
  <pre><code>    for (const val of values) {
          savedLen += val.length;
      }
  </code></pre>
  
  <p>I am getting another error:</p>
  
  <pre><code>    ✘  http://eslint.org/docs/rules/no-restricted-syntax  iterators/generators require regenerator-runtime, which is too heavyweight for this guide to allow them. Separately, loops should be avoided in favor of array iterations
      src\components\entity\Test.vue:171:9
              for (const val of values) {
              ^
  </code></pre>
  
  <p><strong>EDIT2:</strong></p>
  
  <p>This does not produce errors:</p>
  
  <pre><code>    const values = Object.values(this.triggeredTests);
      const sumCalculator = (accumulator, currentValue) =&gt; accumulator + currentValue.length;
      const savedLen = values.reduce(sumCalculator, 0);
  </code></pre>