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

153
Views
Determin Highest Value on Array of Objects

I have this problem where the array of objects is intendedly put into this kind of structure:

const productArray = [
  { 'Product A': 5000 },
  { 'Product B': 2500 },
  { 'Product C': 3500 },
  { 'Product D': 2750 },
  { 'Product E': 1500 },
];

On what way could I determine the highest and lowest value of this kind of array? Thank you very much.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Sort the array, Lowest one will be at first and Largest one will be at last

const productArray = [
  { 'Product A': 5000 },
  { 'Product B': 2500 },
  { 'Product C': 3500 },
  { 'Product D': 2750 },
  { 'Product E': 1500 },
];
const sortedProduct = productArray.sort((a, b) => Object.values(a)[0] - Object.values(b)[0]);
console.log(sortedProduct);
console.log('Lowest value ', sortedProduct[0]);
console.log('Highest value ', sortedProduct[sortedProduct.length - 1]);

about 4 years ago · Juan Pablo Isaza Report
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!