mardi 3 janvier 2017

User defined "IF" statements JS

I have a tonne of data for users of websites detailing their actions online. This data is then used to tailor email campaigns. For example, someone who has clicked a lot of links and is engaged with the company might get more "Special Offer" emails than those who are on the brink of unsubscribing.

I wish to build a tool in a web portal that will allow me tailor the following if statement.

For example:

foreach(users as user)

if(
   user.points > 80
   AND user.date_added > '2012'
   OR user.name="John Doe"
) {
    selected_users.push(user);
}

I must be able to add an unlimited number of conditions, and specify whether it is "AND" or "OR".

I don't know how to loop for an unlimited number of conditions. Could someone give me a hand?

Aucun commentaire:

Enregistrer un commentaire