Trying to retrieve an object from an array called pVal. pVal is the array that includes objects. I am attempting to obtain the value of "group" based on the id provided. For instance, if the id is equal to 1, it should display "VKC". Any assistance would be greatly appreciated.
Here is the code I have experimented with:
this.arr = userData; // -> json
this.pId = this.arr.pId; // could be 1, 2, or 3
pVal: Array<Object> = [{id:1, group:'VKC'},
{id:2, group:'ABC'},
{id:10, group:'DEF'},
{id:3, group:'GHI'},
{id:5, group:'JKL'},]
alert(this.pVal['1'].group);
this.pInd = this.pVal[this.pId].group;