I'm having issues with variable scope. The code below is in Protractor which is a mix of Jasmine and JavaScript. The issue that I'm having is that I'm trying to use string value from householdLabelText and compare it to the value of householdArray[i]. 
However, whenever I do this, householdArray[i] comes back as undefined. I'm guessing this is because householdArray goes out of scope or something. I'm not exactly an expert how the Promise/callback thing works, so I may be wrong. If anyone could give me some tips on how to keep householdArray in scope, I would appreciate it. 
it((testNumber += 1) + '---' + suiteName + '---' +
'It should dispaly the appropraite text for the rating factors.',
    function() {
        var householdArray = ['ACCIDENTS', 'VIOLATIONS', 'DRIVERS', 'VEHICLES', 'TENURE'];
        element.all(by.repeater('item in vm.policyDetails.householdDetails')).then(function(householdDetails) {
            for(var i = 0; i < householdDetails.length; i++)
            {
                householdDetails[i].element(by.binding('item.label')).getText().then(function(householdLabelText) {
                console.log(householdArray[i]);
                expect(householdLabelText).toEqual(householdArray[i]); // householdArray[i] is undefined
                });
            }
        });
    });
 
    