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

397
Vistas
Promise.allsettled returning undefined

I am trying to use promise all settled and I do console log inside the function it gives correct output. After returning this output from promise.allsettled and while I assert this- it shows undefined. Could you please help on identifying the issue?

Please note developerArr is an array element.code()- code is another function resolving promise which returns a string

`console.log("promise all settled ", output, typeof(output))` shows
***promise all settled  console.log("Hello, Nicole!")
System.out.println("Hello, John!")
print("Hello, Pete!") string***

    export default function hackathon(developerArr) {
    //let strMsg = ""
    let output = []
    let promises = []
    let i = 0
   
    developerArr.forEach(element => {
        promises[i] = new Promise((resolve) => {
            resolve(element.code())
        })
        i ++
    })

    Promise.allSettled(promises).then((results) => {
        results.forEach((result) => {
            if (result.value) {
                output.push(result.value)
            }else if (result.reason) {
                output.push(result.reason)
            }
        })
        output = output.join('\n')
        console.log("promise all settled ", output, typeof(output))
        return output.toString()
    })
}


 

    it('should resolve with an error message for an unknown language', async () => {
    const output = await hackathon([
      ...developers,
      new Developer({
        name: 'Adam',
        language: 'abap'
      })
    ])
    var str = [
      'console.log("Hello, Nicole!")',
      'System.out.println("Hello, John!")',
      'print("Hello, Pete!")',
      'Unsupported language: abap'
    ].join('\n')
    console.log(str, typeof(str))
    console.log("output from hack test.js",output, typeof(output))
    
    assert.equal(output, [
      'console.log("Hello, Nicole!")',
      'System.out.println("Hello, John!")',
      'print("Hello, Pete!")',
      'Unsupported language: abap'
    ].join('\n'))
  })
})

`console.log("output from hack test.js",output, typeof(output))` shows 
***output from hack test.js undefined undefined***
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