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

219
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 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