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

73
Vistas
Output showing Undefined using find array helper in javaScript

So, here is the code which is using find helper in javaScript and supposed to return a value but instead of that it is showing undefined.

function Car(model) {
this.model = model;
}
var cars = {
 new Car('Buick'),
 new Car('Camaro'),
 new Car('Focus')
};
cars.find(function(car){
 return car.model === 'Focus';
});

I am running this code in VB and the output supposed to be Focus but it is showing undefined.

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

0

Your cars variable needs to be an array not an object as you don't have keys, just a list. Here is a working example:

function Car(model) {
  this.model = model;
}
var cars = [
  new Car('Buick'),
  new Car('Camaro'),
  new Car('Focus')
];
console.log(cars.find((car) => car.model === 'Focus'));

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