title: How to run a for loop in res.render on a get request in node.js? I am using hbs as view engine
body: <p>In the following code I have to write description 1,2,3 and so on again and again, is there any way I can run a for loop to initialize all the variables?</p>
  
  <p>I have to pass these values to hbs file which will show it in web page. </p>
  
  <pre><code>app.get('/:id/description', (req, res) =&gt; {
    var id = req.params.id;
  
    console.log(id);
  
    descriptionModel.findOne({"header":id}).then((DescriptionModel) =&gt; {
      if (DescriptionModel === null) {
        res.send('Sorry, the page you have requested does not exsist.');
        return res.status(404).send();
      }
  
      res.render('index.hbs', {
        image: DescriptionModel.path,
        id: id,
        header: DescriptionModel.header,
        db_head_image_description1: DescriptionModel.header_image.image_description[0],
        db_head_image_heading1: DescriptionModel.header_image.image_heading[0],
        db_head_image_description2: DescriptionModel.header_image.image_description[1],
        db_head_image_heading2: DescriptionModel.header_image.image_heading[1],
        db_head_image_description3: DescriptionModel.header_image.image_description[2],
        db_head_image_heading3: DescriptionModel.header_image.image_heading[2],
        db_head_image_description4: DescriptionModel.header_image.image_description[3],
        db_head_image_heading4: DescriptionModel.header_image.image_heading[3],
        db_head_image_description5: DescriptionModel.header_image.image_description[4],
        db_head_image_heading5: DescriptionModel.header_image.image_heading[4],
        sub_heading: DescriptionModel.sub_heading,
        sub_heading_tagline: DescriptionModel.sub_heading_tagline,
        sub_heading_data: DescriptionModel.sub_heading_data,
        paralax_image_heading: DescriptionModel.paralax_image_heading,
        paralax_image_tagline: DescriptionModel.paralax_image_tagline,
        gallary_heading: DescriptionModel.gallary_heading,
        gallary_tagline: DescriptionModel.gallary_tagline,
      });
      // console.log(DescriptionModel);
  
    }).catch((e) =&gt; {
      res.status(400).send();
    });
  });
  </code></pre>