Creating WHERE statement from array via JS transformer


I am trying to create a longer WHERE statement from an array. My example array has "foo" and "bar". I manage to loop over the array, however, the output has twice "foo" in it. Can someone help me with a probably pretty obvious mistake? Thanks.

Looks like a scoping issue with your loop which is iterating over a local var but referencing the value of another object within it. Try this instead:

return {{keywordsArray.value}}.map(x => 'lower(title) like "%' + x + '%"').join(' OR ');

Thanks a lot @dcartlidge . That works perfectly and is a lot more elegant.