Can you modify the key while iterating through objects using an external variable? Picture it like this:
var data = [{
"id": 1,
"name": "Simon",
"age": 13
}, {
"id": 2,
"name": "Helga",
"age": 18
}, {
"id": 3,
"name": "Tom",
"age": 27
}, ]
var key = name;
for (var i = 0; i < data.length; i++) {
var output = data[i].key;
}
However, this currently results in an undefined output. The aim is to create a function that can manage various types of loops.