here is my first array
let specificCoin = ["Ethereum","Bitcoin"]
and here is the second one
let coins =[
{
name: 'Bitcoin',
},
{
name: 'Ethereum',
},
{
name: 'Solana',
},
{
name: 'BinanceCoin',
}]
i wondering how can i filter the coins array with includes in specificCoin array something like that:
coins.filter(a => { return a.name.includes(specificCoin) })
result: [{name: 'Ethereum',},{name: 'Bitcoin'}]
and i also would like to know if there are two same objects value how can i get both in it, using this code
let dataAssest = data.map(b => b.assestSymbol.toLowerCase())
let filtered = coins.filter(coin => dataAssest.includes(coin.symbol))
image of result: Wrong result
but that ain’t work, i hope you guys can give a good solution :)
Other way around
let specificCoin = ['ETH', 'BTC'].map(symbol => symbol.toLowerCase())
let coins = [{ id: 'Bitcoin', symbol: 'btc' }, { id: 'Ethereum', symbol: 'eth' }, { id: 'Solana', symbol: 'sol'}, { id: 'BinanceCoin', symbol: 'bnb' }];
const filtered = coins.filter(coin => specificCoin.includes(coin.symbol.toLowerCase()))
console.log(filtered)