Array.push() doesn't affect outer .then scope

The second part of a lambda function after first fetch request:

.then((articles) => {
  var images = [];
  for (let i = 0; i < articles.length; i++) {
    fetch(
      `example.com/${articles}`
    )
      .then((image) => image.json())
      .then((image) => {
        images.push([
          image["parse"]["title"],
          image["parse"]["images"][
            Math.floor(Math.random() * image["parse"]["images"].length)
          ],
        ]);
        console.log(images); \\ logs expected
      });
  }
  console.log(images); \\ logs empty array
  return images;
})

How can the .push() change the outer images variable?

68 thoughts on “Array.push() doesn't affect outer .then scope”