'NodeJS push() is not modift outside scope [duplicate]

I have script for splitting array into smaller chunks. After split i tried to combine images and push data to another array but push method is not modify array. When i try to log new array's length it gives me 0 all the time.

test.js

var portfolioMergedImages = [];

    for (let j = 0; j < portfolioArgsWithChunks.length; j++) {

        combineImages(portfolioArgsWithChunks[j])
        .then(img => {
            portfolioMergedImages.push(img);
        })
    }

    console.log(portfolioMergedImages.length); // returns zero


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source