I have a pug template that receives an array of objects from Node/mongo/express. Based on the maximum value of one the fields (not length), I need to restrict some columns in an html table.
For example, the objects rendered from node might look like this
{
quantity: 4,
years: 6
},
{
quantity: 78,
years: 2
}
I would then need to restrict the number of 'year' columns in my table to be 6. I'm not sure what the best way is to do this, whether to render an additional 'max' variable in node, whether I can do this in pug, or if I should use some client-side js. In (very) pseudo-code, I want something like this...
forEach(Math.max(project.output.years)){
...create an html table 'year' column
}