I want to filter the following array by values. The values including '-usd' need to be replaced without '-usd'. After that I want to only output that replaced values! and not horse or mouse. How can I do this?
So the filtered array may look like:
arr = [
{animal: 'cat', price: 150},
{animal: 'dog', price: 350},
]
So far i made this:
arr = [
{animal: 'cat-usd', price: 150},
{animal: 'dog-usd', price: 350},
{animal: 'horse', price: 5000},
{animal: 'mouse', price: 50}
]
var filter = arr.map((i, k) => {
var ret = i.animal.replace(/-USD/gi, '')
return ret;
})
console.log(filter)