- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-21-2019 03:40 AM
HI Guys,
Quick question, what is the operator for 'contains'?
My condition is: if category contains 'Europe'
How do I translate that?
I tried - if(categoryLikeEurope), it didnt work.
Thank you!
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-21-2019 03:43 AM
Hi,
you have to use the function indexOf.
Please check below an example:
var str = "Hello world, welcome to the universe.";
var n = str.indexOf("welcome");
JavaScript String indexOf() Method
Check also the example in the thread below, it will help you to understand how to use the indexOf in an IF condition:
If I have answered your question, please mark my response as correct so that others with the same question in the future can find it quickly and that it gets removed from the Unanswered list.
Thank you
Cheers
Alberto

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-21-2019 03:57 AM
Happy to know that, welcome 🙂

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-21-2019 03:45 AM
Join the array and the use includes()
var arr = ["one", "two", "three", "four", "five"];
arr = arr.join(',');
gs.info(arr.includes("two"));
//returns true
gs.info(arr.includes("foo"));
//returns false
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-21-2019 03:52 AM
Hi,
You can also use contains() method to check for condition.
For example,
var v=[" Europe","England"];
if(v.contains("Europe"));
Please mark correct/helpful if it helps for you
Regards,
Pooja