I am trying to pass a specific string into "statLocation" to pull data from a javascript object to no avail. This is what I'm attempting:
const statLocation = ".level"
Statistics.getAllStatisticsForGame(gameObj)
.then(stats =>{
for(var i = 0; i <stats.length; i++){
console.log(stats[i] + statLocation );
}
}).catch(console.error);
Below is how I normally would hardcode it but I'm trying to make it dynamic so I can grab specific data and reuse the same method:
Statistics.getAllStatisticsForGame(gameObj)
.then(stats =>{
for(var i = 0; i <stats.length; i++){
console.log(stats[i].level);
}
}).catch(console.error);
How would I be able to add this string to the call? Any advice much appreciated