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

204
Vistas
Find max value in a Javascript Object and print all values

I apologize but I am very new to JavaScript. I have a toy object derived from two arrays. What I want to do is find the largest value of the make parameter (i.e., make = 3) and get an object that has all the parameters (i.e., make and model ) of make equal to 3

const arr1 = [1, 2, 3];
const arr2 = ['a', 'b', 'c'];
const myArr = [];

for(i = 0; i < arr1.length; i++){
    var myCar = new Object();
    myCar.make = arr1[i];
    myCar.model = arr2[i];
    myArr.push(myCar)
}
console.log(myArr);
>>> [ { make: 1, model: 'a' },
  { make: 2, model: 'b' },
  { make: 3, model: 'c' } ]
var mm = Math.max(...myArr.map(o => o.make))
console.log(mm)
>>> 3

I wish {make: 3, model: 'c'}

about 4 years ago · Santiago Gelvez
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