- I need some help with JavaScript programming.
- Although I am able to retrieve values in
sportsRecord
, I am encountering difficulties assigning them totempObj['TigerNo']
. - Whenever I try to assign the value, I encounter the following error message --
TypeError: Cannot read property 'TigerNo' of undefined tempObj['TigerNo'] = this.getDefault(sportsRecord).TigerNo;
- Below is a snippet of relevant code and the full code can be found on gist.
- Can someone please guide me on how to resolve this issue?
- Here's my code snippet for reference:
https://gist.github.com/niniyzni/5c19f385b35f9418086125799803efe7
TypeError: Cannot read property 'TigerNo' of undefined
at playerLionUpdate.setNesetTigerstworks (player-LionUpdate.ts:980)
at SafeSubscriber.eval [as _next] (player-LionUpdate.ts:367)
getDefault(sportsRecord: any){
for(var i=0; i<sportsRecord.length; i++){
if(sportsRecord[i].hasOwnProperty("isDefault"))
{
if(sportsRecord[i].isDefault)
return sportsRecord[i];
break;
}
}
}
setTigers(sportsRecord: any) {
let that = this;
let tempObj = {};
// Relevant code section
...
$("#unSelectedTigersLogoBox1 .currentNwLogo").bind("click", function (e) {
e.stopPropagation();
that.singleSelection(sportsRecord, e);
});
}
sportsRecord = {
playerTigers:[
{TigerNo: 237, TigerName: "Bird Bay Area", TigerkGroupNo: 1, isDefault: true, futureAccessDays: ""},
{TigerkNo: 238, TigerName: "Bird California", TigerkGroupNo: 1, futureAccessDays: ""},
{TigerkNo: 239, TigerName: "Bird Washington", TigerkGroupNo: 1, futureAccessDays: ""},
{TigerNo: 240, TigerName: "Bird Philadelphia", TigerkGroupNo: 1, futureAccessDays: ""},
{TigerNo: 241, TigerName: "TCN", TigerkGroupNo: 1, futureAccessDays: ""},
{TigerNo: 242, TigerName: "Bird Chicago", TigerkGroupNo: 1, futureAccessDays: ""},
{TigerNo: 243, TigerName: "Bird Boston", TigerkGroupNo: 1, futureAccessDays: ""},
{TigerNo: 244, TigerName: "Bird Northwest", TigerkGroupNo: 1, futureAccessDays: ""}
]
}