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

259
Views
How to execute a loop in a dedent block?

Does anyone know how I can execute

req.body.documents.forEach(element => {
    console.log(element['_index']);
    console.log(element['_id']);
    console.log(element['_source'].uuid);
    console.log('--------------------');
});

inside a dedent block?

const description = dedent`

Date:     ${req.body.date}
Alert ID: ${req.body.alert_id}
    
LOG ENTRIES
===========

< Execute loop here >
`;

Or does this need to be solved with a template engine? If, any suggestions how to implement it?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Remember, you can interpolate even complex expressions inside template literals:

`LOG ENTRIES
===========

${
  req.body.documents.map(element => 
    [element._index, element._id, element._source.uuid].join('\n')
  ).join('--------------------\n')
}

`

Then dedent will just take care of extra indentation in the resulting string.

over 4 years ago · Santiago Trujillo 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!