I'm fairly new to asynchronous programming and trying to understand why execution never goes to the 'then' block chained after the promise that contains a 'if'. Can anyone help please ?
var uploadResourceToView = function (edit) {
    var promises = [];
    for (var i = 0; i < inputConfig.length; i++) {
        promises.push(new Promise(function (resolve, reject) {
            var name = 'hey';
            new Promise(function (resolve) {
                if (i == 0) {
                    return new pTree().renamePage('Home', name);
                } else {
                    return edit.addPage(name, '3D')
                }
            })
            // subsequent then()s are never executed 
            .then(function () {
                console.log('why am I not been executed ? ');
                return edit.addObject(object)
            })
            .then(function () {
                return edit.addResource('test resource', true);
            })
            .then(resolve, reject);
        });
    }
    return Promise.all(promises);
}
 
     
    