Array Iteration

well you'd have to have a valid array. but you only want the info value? or you want anything in that place?
UU
Unknown User882d ago
G
ghardin137882d ago
well i'd need to see a valid structure to even remotely guess 🙂
UU
Unknown User882d ago
G
ghardin137882d ago
ok so you have an array and what are you wanting to get out of the array?
UU
Unknown User882d ago
G
ghardin137882d ago
so you could have multiple objects in this outermost array with a time key? and specifically the string "time"?
UU
Unknown User882d ago
G
ghardin137882d ago
ok, so after that you want an array of all of the objects with a location key? are there only locations inside that array?
UU
Unknown User882d ago
G
ghardin137882d ago
and you want a single array of just the items that are inside a "time" key?
UU
Unknown User882d ago
G
ghardin137882d ago
ok, that's less simple but still doable going to take 3 steps rather than 2
UU
Unknown User882d ago
G
ghardin137882d ago
so wait. the "time" string isn't actually the string "time" it's some other string?
UU
Unknown User882d ago
G
ghardin137882d ago
ok that's why i asked
UU
Unknown User882d ago
G
ghardin137882d ago
const times = array.filter(item => item.hasOwnProperty(varHoldingTimeString));
const locations = times.flatMap(item => item[varHoldingTimeString]);
const location = locations.find(location => location.hasOwnProperty(varHoldingLocationString));
const times = array.filter(item => item.hasOwnProperty(varHoldingTimeString));
const locations = times.flatMap(item => item[varHoldingTimeString]);
const location = locations.find(location => location.hasOwnProperty(varHoldingLocationString));
UU
Unknown User882d ago
G
ghardin137882d ago
it's whatever specifies the "time" you want to match
UU
Unknown User882d ago