samedi 31 août 2019

Is it possible to return any one conditional that are true out of multiple ones (in a simple way)?

This has likely already been answered multiple times, but I am unable to find any good answers. I'm probably not searching for the right things..

I have a number of checkboxes that return "on" or "off".

req.query returns these checkboxes.

If they are "on" I would like to push that particular key/val pair to an array for later to be used in a query in mongoDB. I know I can use Object.entries(req.query)to loop through them, but I just want to know if there might be another way like the example below.

let checkboxCol = [];
if (checkboxa, checkboxb, checkboxc, checkboxd) {
    checkboxCol.push(/* any checkbox that is "on" */);
}

Aucun commentaire:

Enregistrer un commentaire