Avatar of Steve Hougom
Steve Hougom
Flag for United States of America asked on

Need help mapping array of number strings ["1","2"] to text descriptions

In my Angular 11 typescript code I am getting back a few fields  from the API in this format.  



In my call to assign the response to a local var i need to swap those above values out and replace them with meaningful descriptions such as:  "some description" instead of the numbers strings.

Here is my call to get data.  





* vscodeAngular* typescript programming

Avatar of undefined
Last Comment
Steve Hougom

8/22/2022 - Mon
leakim971

const eligibility = {
   1: "desc1",
   2: "desc2",
   3: "desc3",
   4: "desc4",
}
const items = response.map(x => eligibilty[x]);

Open in new window

Steve Hougom

ASKER
Having some trouble making this work.  Im trying to alter my local typescript model class called FormData.
you can see the eligibility field in there.  So when I get the response I assign it to this FormData Class.  You can see the response in a previous message screenshot.  






ASKER CERTIFIED SOLUTION
Steve Hougom

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes