Question: function cityWithLowTemp(dbConnection){ return new Promise(function(resolve){ var returnArray = []; for (var i = 0; i

function cityWithLowTemp(dbConnection){ return new Promise(function(resolve){ var returnArray = []; for (var i = 0; i

}

}); resolve(returnArray); }

});

}

test(); async function test(){ var dbConnection = await connectToDB(); console.log(dbConnection); var coldTempArray = await cityWithLowTemp(dbConnection); console.log(coldTempArray); }

dbConnection that is passed onto the cityWithLowTemp function is just an array of zip codes. I'm trying to figure out where I should put the resolve(returnArray). The code is correctly pushing the message into returnArray but it either resolves with one item in the array or none at all. Where can I put the resolve where it will correctly return the entire array. This is in javascript.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!