我想根据循环内计算变量的值增加不同的变量。我在循环外声明变量,但一旦进入循环,它们就变得不确定。为什么会这样?
class ApplicationRecord < ActiveRecord::Base
self.abstract_class = true
end
这是var fetchedDesignOpps = function (designopps)
{
var oppAging30 = 0; //typeof returns 'number'
var oppAging60 = 0; //typeof returns 'number'
var oppAging90 = 0; //typeof returns 'number'
$.each(designopps.cards, function (index, designopp)
{
console.log(typeof oppAging30); //typeof returns 'undefined' - WHY??
var displayDate = ( convertDate(designopp.dateLastActivity) );
console.log(displayDate); //returns either 30, 60, or 90. typeof returns 'number' - this part is working
if (displayDate == 30)
{
oppAging30++;
} else if (displayDate == 60)
{
oppAging60++;
} else
{
oppAging90++;
}
});
};
designopps.cards