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

92
Vistas
Array contains duplicate, implementation not working with the forEach syntax

I am trying to create a function if an array of integers has duplicate values, so I came up with the following implementation, and it works:

const containsDuplicate = (nums) => {
    const hashTable = {}
    
    for (let num in nums) {
        const numValue = nums[num]
        if (numValue in hashTable) return true
        hashTable[numValue] = "a"
    }
    
    return false
};

But, I want to know a semantic way to implement this following ES6 style, I tried the .forEach but, I discovered that I cant break out of it.

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