Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

202
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!