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

209
Views
How to find the maximun value in a dictionary in javascript

I have a dictionary that looks like this

let highest_prob_list = {
   "hi": 100,
   "bye": 1,
};

I need to find the key with the greatest value in the dictionary.

For example, I would like "hi" from the object above.

How can i achieve this?

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

0

Use Object.keys to get the properties of the object, then reduce over the array to get the property with the highest value.

let obj = {
   "hi": 100,
   "bye": 1,
};

let props = Object.keys(obj)
const res = props.reduce((a,b) => a = obj[b] > obj[a] ? b : a, props[0])
console.log(res)

about 4 years ago · Juan Pablo Isaza Report

0

const findMax = () => {
  const highest_prob_list = {
    "hi": 100,
    "bye": 1,
  }
  const keys = Object.keys(highest_prob_list)

  let max = keys[0]

  keys.forEach(key => {
    if (highest_prob_list[key] > highest_prob_list[max]) {
      max = key;
    }
  })

  return max;
}
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!