Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

167
Vistas
Remove objects from array where an attribute is equal to specific string

I am using an array.filter() function to remove all the objects where one of their attribute is equal to any of the string in a given array. The objects in the array are crypto trades and I need to filter out the trades with the trade pairs that I do not want. How would I achieve this using the filter function? For now, I tried this which did not work evidently:

filteredPairs = filteredPairs.filter(
      (pair) =>
        !pair.symbol.includes(
          "USDTBUSD",
          "USDTUSDC",
          "USDTUST",
          "USDTUSDP",
          "USDTDAI",
          "BUSDUSDT",
          "BUSDUSDC",
          "BUSDUST",
          "BUSDUSDP",
          "BUSDDAI",
          "USDCUSDT",
          "USDCBUSD",
          "USDCUST",
          "USDCUSDP",
          "USDCDAI",
          "USTUSDT",
          "USTBUSD",
          "USTUSDC",
          "USTUSDP",
          "USTDAI",
          "USDPUSDT",
          "USDPBUSD",
          "USDPUSDC",
          "USDPUST",
          "USDPDAI",
          "DAIUSDT",
          "DAIBUSD",
          "DAIUSDC",
          "DAIUSDP",
          "DATUST"
        )
    );

This is not filtering out these pairs. Any insight would be helpful. Thank you.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

This can be done in a single line.

// testing object
const filteredPairs = [
    {
        symbol: 'USDTBUSD',
    },
    {
        symbol: 'abc',
    },
    {
        symbol: 'BUSDUSDT',
    },
    {
        symbol: '321',
    },
];

// items we don't want
const blacklist = [
    'USDTBUSD',
    'USDTUSDC',
    'USDTUST',
    'USDTUSDP',
    'USDTDAI',
    'BUSDUSDT',
    'BUSDUSDC',
    'BUSDUST',
    'BUSDUSDP',
    'BUSDDAI',
    'USDCUSDT',
    'USDCBUSD',
    'USDCUST',
    'USDCUSDP',
    'USDCDAI',
    'USTUSDT',
    'USTBUSD',
    'USTUSDC',
    'USTUSDP',
    'USTDAI',
    'USDPUSDT',
    'USDPBUSD',
    'USDPUSDC',
    'USDPUST',
    'USDPDAI',
    'DAIUSDT',
    'DAIBUSD',
    'DAIUSDC',
    'DAIUSDP',
    'DATUST',
];

// filter
const newFilteredPairs = filteredPairs.filter(({ symbol }) => !blacklist.some((item) => symbol.includes(item)));

console.log(newFilteredPairs);

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda