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

232
Vistas
How could i get all values out?

Here is the assignment I have. Declare a function getAllValues. You may need to use both kinds of for loops!

/**
* @param {Array} ???
* @returns {Array} an array of all of the values in all of the given objects
*/
function getAllValues(arrayOfObject){ 
    let arr = [];
    for(const e of arrayOfObject){
        let obj = arrayOfObject[e];
        for(const key in obj){ 
            arr.push(obj[key]) ;
        } 
    }
    return arr;
}

// test
test(getAllValues(collection), [1, 2, 3, 3, 4, 100]); // returns []
test(getAllValues(collection.slice(1)), [3, 3, 4, 100]); // returns []

What's wrong with my current code?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Looks like the error is here:

let obj = arrayOfObject[e];  

Here the variable e itself is the object from the array, not an index. So it should be:

let obj = e;
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