Reputation: 1616
I want to map 2 values from Interface:
export interface CurrenciesList {
currency: string;
country: string;
}
I want to map the result like this:
this.optionValues["currency"] = value.map(i => ({ id: i.currency, name: i.currency }));
But I would like to combine the result like this:
this.optionValues["currency"] = value.map(i => ({ id: i.currency, name: i.currency - i.country }));
But I get And as result. I would like to get this result into the list:
USD - United States
What is the proper way to map this: name: i.currency - i.country
Upvotes: 0
Views: 42
Reputation: 42536
You can try this. I am using ES6's template literals, if you are not familiar with this syntax. It can make string concatenation cleaner in some cases.
this.optionValues["currency"] = value.map(i => ({ id: i.currency, name: `${i.currency} - ${i.country}` }));
Upvotes: 1