Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

165
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!