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

105
Vistas
how to use 3 functions that return an object in javascript?

hey guys so i'm a beginning of javascript and I have a question... I have 3 functions let's say:

const a = (x, y, z) => {
 return {x, y, z}
}

const b = (a, b, c) => {
 return {a, b, c}
}

const c = (d, e, f) => {
 return {d, e, f}
}

let's say I want to make use of these return values in another function, so..

   const p = () => {
   const arr = [returned value from function a, returned value from function b, returned value from function c]
return arr
    }

how would I somehow use the objects that functions a, b, c in order to return an array of objects from function p?

thank you!

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

0

Following what you have asked:

const result1 = a(1, 'dog', null)
// result1 would be { x: 1, y: 'dog', z: null }

const result2 = b('cat', 2, null)
// result1 would be { a: 'cat', b: 2, c: null }

const result3 = c(3, 4, 'pig')
// result3 would be { d: 3, e: 4, f: 'pig' }

Therefore if you made the p function:

const p = () => {
    return [ a(1, 'dog', null), b('cat', 2, null), c(3, 4, 'pig') ]
}

const result1 = p()
// result1 would be: 
// [ 
//   { x: 1, y: 'dog', z: null }, 
//   { a: 'cat', b: 2, c: null }, 
//   { d: 3, e: 4, f: 'pig' } 
// ]

It would be far more likely that p would take some kind of arguments, then would use them inside. For example:

const p = (arg1, arg2, arg3) => {
     return [ a(arg1, arg2, arg3), b(arg1, arg2, arg3), c(arg1, arg2, arg3) ]
}

const result2 = p(1, 'dog' null)
// result2 would be:
// [ 
//   { x: 1, y: 'dog', z: null }, 
//   { a: 1, b: 'dog', c: null }, 
//   { d: 1, e: 'dog', f: null } 
// ]
about 4 years ago · Juan Pablo Isaza Denunciar

0

const one = (a, b, c) => {
  return {a, b, c};
}

const two = (a, b, c) => {
  return {a, b, c};
}

const three = (a, b, c) => {
  return {a, b, c};
}

const result = () => {
  let firstObj = one(10,20,30);
  let secondObj = two(40,50,60);
  let thirdObj = three(70,80,90);
  // Returns all of the objects in an array.
  return [firstObj, secondObj, thirdObj];
}

console.log(result());

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