i made a map with fetch and split the result, and push to other variable but when i try to acess it give's undefined
const arrayPokemons = Array(5)
.fill()
.map((item, index) => {
let hold = [];
fetch(`https://pokeapi.co/api/v2/pokemon/${index + 1}`)
.then((res) => res.json())
.then((data) => {
hold.push(data.name.split(""));
});
console.log(hold, " INTO THE MAP");
return hold;
});
console.log(arrayPokemons, "ALL ARRAYS");
console.log(arrayPokemons[0], "SPECIFC ARRAY");
console.log(arrayPokemons[0][0], "SELECTED ARRAY, BUT RETURN undefined");