The array keys are going to be dynamic but there are only two array items. For example the key start_location.A
has a value of London
and the key start_location.F
has a value of Manchester
I can get the values like this
var start_location_A = result.routes[0].legs[c].steps[b].start_location.A;
var start_location_F = result.routes[0].legs[c].steps[b].start_location.F;
But the A
and F
will be dynamic, meaning the letters will be changing. How do i get the first & second items in the start_location
array regardless of key name? I attempted below but says start_location.index is not a function.
var start_location_A = result.routes[0].legs[c].steps[b].start_location;
start_location_A = start_location_A.index(0);
var start_location_F = result.routes[0].legs[c].steps[b].start_location;
start_location_F = start_location_F.index(1);
How do i solve?