title: JavaScript Object: Cannot add new property to Object
body: <p>I simply want to add another property that display course name when enrollments for a user are grabbed.</p>
  <pre><code>router.get('/enrollments/courses/me', auth, async (req,res)=&gt;{
      user_id = req.user._id
      try{
          let Courses = await Enrollment.find({user_id})
          for(x in Courses){
              if(!Courses[x].course_id){
                  throw new Error(&quot;No enrollments found for this student.&quot;)
              }
               courseName = await Course.findById(Courses[x].course_id)
               Courses[x].course_name = courseName.Course_Name
               console.log(Courses[x])
          }
          res.status(201).send(Courses)
      }catch(e){
          res.status(400).send(e)
      }
  })
  </code></pre>
  <p>Example:
  Courses =</p>
  <pre><code>[
      {
          &quot;_id&quot;: &quot;607768e5e8105058546f658a&quot;,
          &quot;user_id&quot;: &quot;606e476107a74d49c4757c1f&quot;,
          &quot;course_id&quot;: &quot;60722e7392d7c6539c344a83&quot;,
          &quot;createdAt&quot;: &quot;2021-04-14T22:12:53.527Z&quot;,
          &quot;updatedAt&quot;: &quot;2021-04-14T22:12:53.527Z&quot;,
          &quot;__v&quot;: 0
      },
      {
          &quot;_id&quot;: &quot;60777e7d6b2bff6040f46f58&quot;,
          &quot;user_id&quot;: &quot;606e476107a74d49c4757c1f&quot;,
          &quot;course_id&quot;: &quot;60722e8b92d7c6539c344a86&quot;,
          &quot;createdAt&quot;: &quot;2021-04-14T23:45:01.881Z&quot;,
          &quot;updatedAt&quot;: &quot;2021-04-14T23:45:01.881Z&quot;,
          &quot;__v&quot;: 0
      },
      {
          &quot;_id&quot;: &quot;607787ec9f21525d644855a8&quot;,
          &quot;user_id&quot;: &quot;606e476107a74d49c4757c1f&quot;,
          &quot;course_id&quot;: &quot;60722e8392d7c6539c344a85&quot;,
          &quot;createdAt&quot;: &quot;2021-04-15T00:25:16.734Z&quot;,
          &quot;updatedAt&quot;: &quot;2021-04-15T00:25:16.734Z&quot;,
          &quot;__v&quot;: 0
      },
      {
          &quot;_id&quot;: &quot;6078d78ea1ee7f05f89a3c17&quot;,
          &quot;user_id&quot;: &quot;606e476107a74d49c4757c1f&quot;,
          &quot;course_id&quot;: &quot;60722e6b92d7c6539c344a82&quot;,
          &quot;createdAt&quot;: &quot;2021-04-16T00:17:18.941Z&quot;,
          &quot;updatedAt&quot;: &quot;2021-04-16T00:17:18.941Z&quot;,
          &quot;__v&quot;: 0
      }
  ]
  </code></pre>
  <p>courseName =</p>
  <pre><code>{
    &quot;_id&quot; : &quot;60722e6b92d7c6539c344a82&quot;,
    &quot;Course_Name&quot; : &quot;Course_1&quot;,
    &quot;Description&quot; : &quot;This is my 1rst course&quot;,
    &quot;__v&quot; : 0
  }
  </code></pre>
  <p>I loop through each enrollment and make another call to grab the Course name and add it to each object like so</p>
  <pre><code>Courses[x].course_name = courseName.Course_Name
  </code></pre>
  <p>The course name does not appear when I return Courses</p>
  <p>I can do this :</p>
  <pre><code>Courses[x].course_id = courseName.Course_Name
  </code></pre>
  <p>and the course name appears for the course_id, but obviously I don't want to do that.
  This is how Ive added new properties to an Object before, why is this method not working?</p>