Last active
January 15, 2016 18:10
-
-
Save josebalius/01afc522d3337f866e47 to your computer and use it in GitHub Desktop.
Conditions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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