I've been struggling to fetch a specific value ("isRight") from a JSON object. I have tried multiple solutions found on stackoverflow and even compared my code with one of them, but I keep getting the value as undefined without any errors.
{
"QuestionID" : "1",
"Question" :"The ozone layer restricts: ",
"OP" :["X-rays and gamma rays" ,
"Visible light",
"Infrared radiation",
"Ultraviolet radiation" ],
"isRight" :"Ultraviolet radiation"
},
{
"QuestionID" : "2",
"Question" :"The length of the bridge, which a train 130 metres long and travelling at 45 km/hr can cross in 30 seconds, is:",
"OP" :["200 m" ,
"225 m",
"245 m",
"250 m" ],
"isRight" :"245 m"
},
.ts:
filterAnswer(i:number)
{
for(i=1 ; i <= this.questArrayNew1.length ; i++)
{
console.log(i);
console.log(this.questArrayNew1);
this.isRyt = this.questArrayNew1.find(x=>x.QuestionID == i).isRight;
}
}
I am aiming to save the retrieved value in the variable 'isRyt'.