New to coding & learning javascript & node.js. I have an array of 50 image results here: http://mistakes.io/#6204f3edd56b8891075d
I am trying to pull out two specific objects in that array: "MediaUrl" and "SourceUrl".
I can pull out an individual result via body.d.results[15].MediaUrl
for example, but how do I pull out all 50 MediaUrl or SourceUrl? I was thinking that I could achieve this with a for of for-in loop but unclear how to do so. The goal is to pull those objects out and then be able to pick randomly from those specific elements. Would I first have to create a variable with an array like var myArray = ["body.d.results[0].MediaUrl", body.d.results[1].MediaUrl", body.d.results[3].MediaUrl", ...]
?
Any help is greatly appreciated. I have been searching up and down for examples and tutorials but not sure how to phrase what I am looking for. I believe this question is different than here: From an array of objects, extract value of a property as array because it doesn't explain how to pick randomly as well.