Skip to content

Instantly share code, notes, and snippets.

@josebalius
Last active January 15, 2016 18:10
Show Gist options
  • Save josebalius/01afc522d3337f866e47 to your computer and use it in GitHub Desktop.
Save josebalius/01afc522d3337f866e47 to your computer and use it in GitHub Desktop.
Conditions
var conditions = [
{
column: "name",
operator: "=",
value: "John"
},
{
join: "OR"
},
{
column: "name",
operator: "=",
value: "Ally"
}
]
var person = {
name: "Ally",
age: 20
}
var evaluateConditionsOnObject = function(obj, conditions) {
// Implement this function
}
console.log(evaluateConditionsOnObject(person, conditions))
// Should be true
var secondConditions = [
{
column: "name",
operator: "=",
value: "Ally"
},
{
join: "AND"
},
{
column: "age",
operator: "=",
value: "21"
}
]
console.log(evaluateConditionsOnObject(person, secondConditions))
// Should be false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment