Struggling with extracting only the localized names from a JSON/Array related to a popular video game. Despite being close, I can't seem to create a new array correctly. Can anyone spot what's missing in my code?
const endpoint = './heroes-org.json'
let heroes = []
let renamed = []
fetch(endpoint)
.then(text => text.json())
.then(data => heroes.push(...data.result.heroes))
.then(() => {
for(i = 0; i < heroes.length; i++){
// renamed += heroes[i].localized_name
//heroes.map(function){
//}
setTimeout(function(){
console.log(renamed)
}, 2000)
}})
Experimenting with the map function as a way to eliminate unnecessary keys within each element of the array.
When I try to console log heroes
directly in the Chrome console, the output appears disjointed:
https://i.sstatic.net/tE023.png
This fragmented indexing seems odd. What might be causing my array to split into segments?
The end goal is to consolidate all 115 hero names into a single array.