I have an array like,
0: "City1"
1: {name="sds", age="asd",....}
2: {name="sweds", age="accxsd",....}
3: {name="sdqws", age="asssd",....}
4: "City2"
... and many more
So I need to get the elements between index[0] and index[4],
Am able to check the string and object using typeof
for(i=0; i<=arr.length; i++){
if(typeof arr[i] == 'string'){
... // need to find next element eith type string
}
}
Is there a way to find the next element in an array whose value is string, so I can get elements between them.
arr[i+1]?[ { "name": "city1", "people": [ { "name": "sds", age: "asd" }, { "name": "sweds" ... ] }, { "name": "city2", "people: [....etc