3

I am taking some random entry from MongoDB. I am just trying to append some additional data to it and send it to the front-end. I have done this several times, but for some reason cannot get it working.

var activity = {}
activity =  activities[Math.floor(Math.random() * activities.length)]
activity.fgg = "HIII" 
console.log(activity)

It doesn't append fgg? Why is that? However, if I make ANOTHER object and do obj.activity = activity and obj.ff = "hii". it DOES append but not in the format I want (obj inside obj). What is happening?

Output is:

{ __v: 0,
  activity: 'Go for a walk outside',
  name: 'Let your inner eagle SOUR!',
  _id: 56c21cc39686e94b7918bc58 }

Where is fgg?

JJJ
  • 32,902
  • 20
  • 89
  • 102
Newbie
  • 152
  • 10

0 Answers0