let movies = [];
fetch(endPoint)
.then((res) => res.json())
.then((data) =>
{
// console.log(data);
data.results.forEach((element) =>
{
movies.push(element.id);
})
console.log(movies);
for(let i = 0; i < movies.length; i++)
{
console.log(movies[i]);
}
})
console.log(movies);
So I am fetching an API and putting all the id's returned from the results array into my array of movies. How come my array values from movies are being printed differently outside my fetch block?