Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

167
Visualizações
getting single value while returning in node js / javascript

I am trying to return value from my customer function but the problem is I am getting single value

customerDetails.js

function customerDetails(obj, customerId) {
  let type, access_id, info, entry_available;

  for (i = 0; customerId[obj.data.target.sys.id].locale.length > i; i++)
    for (const detail of customerId[obj.data.target.sys.id].locale) {
      type = obj.member;
      access_id = obj.id.replace(/-/g, "_");
      info = obj.info;
      entry_available = {};
      if (obj.data.target.sys.id in customerId) {
        entry_available = {
          "customer-id": obj.data.target.sys.id,
          locale: detail,
          "shop-id": customerId[obj.data.target.sys.id].shop_id,
        };
      }
      // console.log( access_id, type, entry_available, info ); // here I am getting all the values
      return { access_id, type, entry_available, info };
    }
}

so here you can the place where I am writing console.log() I am getting all the values there so I return the value as I want to return exactly the same way but It returning single value is there any possible way I can return all the values which I am getting in same format ?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

assuming, that you want to have your values returned in single variables:

there is no way to return multiple values plain in javascript like it is possible in, i believe, python, but you can use destructuring to your advantage.

function customerDetails ( obj, customerId ) {
    let type, id, info;
    // ...
    return { type, id, info };
}

const { type, id, info } = customerDetails(/* ... */);

read more about destructuring here

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda