-1
I need to increment a property path
in a ajax
, I need to add numbers in front of the property in a for and receive its value, follow example:
data.data[0].genero1
I need to get the genero2
now, I tried that but it didn’t work:
for (var i = 1; i <= 5; i++) {
var p = "genero"+i;
console.log(p);
console.log(data.data[0].p);
}
That one for
above does not give error, but returns undefined
To var p
returns the string correctly, the second console.log
that gives undefined
Because the "-1" ?
– Alan PS