I'm trying to create a function which will replace array values with its matching object value. I've tried using .filter. However, it will not allow for duplicate values as seen in the example below.
Current code
fetchInventory: async function () {
await Object.entries(this.$store.state.inventory).forEach(([k, v]) => {
for (let i = 0; i < parseInt(v); i++) this.inventory.push(parseInt(k))
})
const items = JSON.parse(localStorage.getItem('priceCache'));
const filteredItems = await items.list.filter(i => this.inventory.includes(i[0]));
this.inventory = await filteredItems;
}
Input
var array = [1208, 1209, 1209]
Current output
var output = [[1208, 'returned item'], [1209, 'returned item']]
Expected output
var output = [[1208, 'returned item'], [1209, 'returned item'], [1209, 'returned item']]

array?awaitis required in each of those lost two lines.[1208, 1209, 1209].map(e => [e, 'returned item'])