Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] Using var operator at nested level of array operators #113

Open
alxpsr opened this issue Jul 29, 2022 · 2 comments
Open

[Question] Using var operator at nested level of array operators #113

alxpsr opened this issue Jul 29, 2022 · 2 comments

Comments

@alxpsr
Copy link

alxpsr commented Jul 29, 2022

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 ^_^

@jakemedal
Copy link

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.

@alxpsr
Copy link
Author

alxpsr commented Jan 31, 2023

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants