I am trying to make a JSON, but get a type error.
The error says, cannot set property 'apps' of undefined. This happens at the *.isFav = true
statement. If I remove the if statement it works ( the isFavt(*) statement).
Any help will be appreciated. Thanks!
pref.userid = username;
//systems
systems = [];
for(i=0;i<system.length;i++)
{
systems[i] = new Object();
systems[i].systemid = system[i];
systems[i].apps = [];
j = 0;
$('.save label').each(function ()
{
lst = $(this).text();
console.log(systems[i]);
systems[i].apps[j] = new Object();
systems[i].apps[j].name = lst;
systems[i].apps[j].href= findHref(lst.toLowerCase().replace(/ /g,'_'));
//seq
systems[i].apps[j].seq = j;
//check for favourites
if(isFavt(lst))
systems[i].apps[j].isFav = 'true';
else
systems[i].apps[j].isFav = 'false';
//check for default
if(isDef(lst) == true)
systems[i].apps[j].isDef = 'true';
else
systems[i].apps[j].isDef = 'false';
//subapps
j = j + 1;
});
}
pref.systems = systems;
return pref;
}