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

94
Vistas
Rerurn filtered array which is not equal to another array list

I've a api with list of car.

const getAsset = async () => dbApi('list_cars', ['', 100])
     .then(result => result.map(e => e.symbol));

here, getAsset returns the car list.

0: "BMW"
1: "HONDA"
2: "SCODA"
3: "STAR"
4: "PETH"
5: "TEST"
6: "TESLA"

In the below code block, I tried to return list excluding BMW. And it worked well.

 const getAsset = async () => dbApi('list_cars', ['', 100])
     .then(result => result.filter(e => e.symbol != 'BMW' ).map(a => a.symbol));

Now, I want to go forward and return the list of car excluding BMW , HONDA and TEST.

const expect = ['BMW','HONDA','TEST'];

expected result :

0: "SCODA"
1: "STAR"
2: "PETH"
3: "TESLA"

What changes should I make in the above code block?

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

0

You can do it by filter method, like this:

const cars = ["BMW","HONDA", "SCODA", "STAR", "PETH", "TEST", "TESLA"]
const except = ["BMW","HONDA","TEST"];

const filteredCars = cars.filter(car => !except.includes(car));
console.log(filteredCars)

about 4 years ago · Juan Pablo Isaza Denunciar

0

 const getAsset = async () => dbApi('list_cars', ['', 100])
     .then(result => result.filter(e => (e.symbol != 'BMW' && e.symbol != 'HONDA' && e.symbol != 'TEST') ).map(a => a.symbol));

about 4 years ago · Juan Pablo Isaza Denunciar

0

 const cars = ["BMW","HONDA", "SCODA", "STAR", "PETH", "TEST", "TESLA"];
 
 const filteredResult =  cars.filter(e => (e != 'BMW' && e != 'HONDA' && e != 'TEST'));

console.log(filteredResult);

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