I've been trying to make the ObjectArray print The key value without having to specify userData [i] .name; userData [i] .lastname; userData [i] .age;
Just put the key in an array like:
You could try something like this:
for(var i = 0; i < userData.length; i++) {
for(var j = 0; j < variables.length; j++) {
console.log(userData[i][variables[j]]);
}
}
Result:
Alan
Gamez
19
Jose
Hernandez
21
Miguel
Aleman
93