json-logic-js
json-logic-js copied to clipboard
[Question] Using var operator at nested level of array operators
Suppose I have two arrays:
-
var arr1 = [ 52, 66, 88, 43, 98 ]
-
var arr2 = [ 41, 42, 43, 45, 46, 49, 52, 53, 79 ]
If some value from arr1
exists in arr2
i wanna return true
/** JS Implementation */
function check() {
return arr1.some(item => {
if (arr2.some(c => c == item)) {
console.log(item)
return true
}
return false
})
}
I tried to do this with var
operator and some
but seems that scope of some
has only local variables and doesn't have variables from closure.
Is there a way to achieve it with default json-logic operators? (i mean without adding new operators via json-logic.add_operator()
)
Thanks in advance ^_^
Hi @alxpsr, I actually have the same use case. Did you come up with a solution for this? Or did you end up implementing a custom operator?
Thanks.
Hi @jakemedal , as far as i understood there is no standard operators for this. Out team implemented custom logic, but via C# on backend (since we use json-logic at frontend and backend)