samedi 8 septembre 2018

simple way to pair any statement in javascript

hi i have 5 statement and i need to pair them all randomly like

let WhereConditions = {}

if (body.sku_voucher && body.available_status) {
    WhereConditions = body.sku_voucher && body.available_status
}
if (body.sku_voucher && body.available_status && body.created_at) {
    WhereConditions = body.sku_voucher && body.available_status && body.created_at
}
if (body.sku_voucher && body.available_status && body.created_at && body.created_by) {
    WhereConditions = body.sku_voucher && body.available_status && body.created_at && body.created_by
}

and there is a posibility the first if statement become

if (body.sku_voucher && body.created_at) {
    WhereConditions = body.sku_voucher && body.created_at
}

and etc,,,

is any another or a simple way to create this?

Aucun commentaire:

Enregistrer un commentaire