R
Reactiflux

Array Iteration

Array Iteration

Gghardin13711/17/2021
well you'd have to have a valid array. but you only want the info value? or you want anything in that place?
UUUnknown User11/17/2021
Message Not Public
Sign In & Join Server To View
Gghardin13711/17/2021
well i'd need to see a valid structure to even remotely guess 🙂
UUUnknown User11/17/2021
2 Messages Not Public
Sign In & Join Server To View
Gghardin13711/17/2021
ok so you have an array and what are you wanting to get out of the array?
UUUnknown User11/17/2021
Message Not Public
Sign In & Join Server To View
Gghardin13711/17/2021
so you could have multiple objects in this outermost array with a time key? and specifically the string "time"?
UUUnknown User11/17/2021
Message Not Public
Sign In & Join Server To View
Gghardin13711/17/2021
ok, so after that you want an array of all of the objects with a location key? are there only locations inside that array?
UUUnknown User11/17/2021
Message Not Public
Sign In & Join Server To View
Gghardin13711/17/2021
and you want a single array of just the items that are inside a "time" key?
UUUnknown User11/17/2021
Message Not Public
Sign In & Join Server To View
Gghardin13711/17/2021
ok, that's less simple but still doable going to take 3 steps rather than 2
UUUnknown User11/17/2021
Message Not Public
Sign In & Join Server To View
Gghardin13711/17/2021
so wait. the "time" string isn't actually the string "time" it's some other string?
UUUnknown User11/17/2021
2 Messages Not Public
Sign In & Join Server To View
Gghardin13711/17/2021
ok that's why i asked
UUUnknown User11/17/2021
Message Not Public
Sign In & Join Server To View
Gghardin13711/17/2021
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));
UUUnknown User11/17/2021
Message Not Public
Sign In & Join Server To View
Gghardin13711/17/2021
it's whatever specifies the "time" you want to match
UUUnknown User11/17/2021
Message Not Public
Sign In & Join Server To View

Looking for more? Join the community!

R
Reactiflux

Array Iteration

Join Server