title: Correct way to loop through an JSON object
body: <p><a href="https://stackoverflow.com/questions/36650674/unable-to-iterate-through-json-array">Since there seems nobody is able to find a solution for my problem</a>, I would like to ask my question in a different way:
  What should be the correct way to loop through the games section of the following object:</p>
  
  <pre><code>[
      {
          "_id": "5710b0ddab8b724011705037",
          "username": "test",
          "name": "testuser",
          "__v": 0,
          "library": {
              "games": [
                  {
                      "platform": [
                          "17",
                          "94"
                      ],
                      "name": "Simcity",
                      "id": "37620"
                  },
                  {
                      "platform": [
                          "146",
                          "20"
                      ],
                      "name": "destiny",
                      "id": "36067"
                  }
              ],
              "platforms": [
                  {
                      "name": "Xbox360",
                      "id": "20"
                  },
                  {
                      "name": "PC",
                      "id": "94"
                  }
              ]
          }
      }
  ]
  </code></pre>
  
  <p>This object is fetched out through mongoose out of a MongoDB, all happens in the API section of my NodeJS application:</p>
  
  <pre><code>.get('/test', function(req, res){
      User.findOne({"username": req.decoded.username}, function(err, user){
  
          // trying to loop here
  
      });
  })
  </code></pre>
  
  <p>I have tried everything I find, but I cannot get it to work, so I wonder what ways you use to do this, without cluttering your vision with my (maybe wrong) ways and errors...</p>