title: Problem with using for-in/of when returning an object in a function
body: <p>I just got the result  &quot;[object Object]'s score is 0&quot;  printed on the terminal.
  The result 27 was all fine until I separated the function into a return object.</p>
  <ol>
  <li>How do I get 27 if I have to return an object?</li>
  <li>How do I get &quot;alex&quot; printed on the console.log instead of [object Object]?</li>
  </ol>
  <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 alex = {
    first: [1, 2, 9, 8],
    second: [3],
    third: [0, 0, 0, 1, 3]
  };
  const gordon = {
    first: [3],
    second: [2, 2, 4, 5, 6, 6, 7, 8]
  }
  
  function createPlayer(object) {
    let score = 0;
    return {
      add: function() {
        for (const key in object) {
          for (const item in object[key]) {
            score += object[key][item]
          }
        }
      },
      result: function() {
        return `${object}\'s score is ${score}`
      }
    }
  }
  createPlayer(alex).add()
  console.log(createPlayer(alex).result())</code></pre>
  </div>
  </div>
  </p>