I have a data array like this,
tourGuide: [
{"location": "london"},
{"location": "paris"},
{"location": "frankfurt"}
]
I want to rewrite the tourGuide so that it will contain the indices too. so it will become something like:
tourGuide: [
{"location": "london", "index":0},
{"location": "paris", "index":1},
{"location": "frankfurt","index":2}
]
I tried this:
var x, l=0;
for(x in tourGuide){
tourGuide["index"] = l;
l++;
}
but that may not be right approach.