- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2022 04:48 AM
Dear community,
Please help me to achieve this. what I want to achieve is to get only unique values from the below 2 variables.
var a = '88034e4497021110b549bfb6f053af6d,1364b04297865110b549bfb6f053af5e' ;
var b = '04034e4497021110b549bfb6f053af73,88034e4497021110b549bfb6f053af6d';
I need to get only the unique values as below
var result = '88034e4497021110b549bfb6f053af6d,1364b04297865110b549bfb6f053af5e,04034e4497021110b549bfb6f053af73';
But am getting as below, which is not correct.
var result = '88034e4497021110b549bfb6f053af6d,1364b04297865110b549bfb6f053af5e,04034e4497021110b549bfb6f053af73,88034e4497021110b549bfb6f053af6d';
Thanks in advance..
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2022 04:58 AM
Hello,
You need to split your result into array and then use unique method of array util
Please refer below background script
var result = '88034e4497021110b549bfb6f053af6d,1364b04297865110b549bfb6f053af5e,04034e4497021110b549bfb6f053af73,88034e4497021110b549bfb6f053af6d';
var arr = result.split(','); // split your string into array first
var arrayUtil = new ArrayUtil();
var arr1= arrayUtil.unique(arr);
gs.log(arr1); // unique array
Please let me know if you need any other help
Thanks,
Valmik
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-26-2024 10:02 AM
Extremely useful reply, thanks!