How to store multiple arrays in a parent array?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-02-2023 07:59 AM
I'm having two arrays
array 1 = [ a, b,c]
array 2 = [x,y,z]
Now I need to store all these two array's in some place and if I call a[0] then I need to get output as a,b,c and if I print a[1] then I need output as x,y,z
can some one please help me how to satisfy this requirement?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-02-2023 08:18 AM
You can save the length of both the arrays
then start pushing the array elements in a single array
Where ever you require the array you can run a loop and from 0 to length of first array or length of first array till end for second array and create the array again
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-02-2023 08:27 AM
Hi @Sathwik1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-02-2023 10:33 AM
Hi,
Thanks for sharing the code, but after pushing array1 and array2.. I'm passing mail through to email script through event.. in email script.. array[0] is not working..can you please help me what I did the mistake?
var ar1 = [1,2,3,4]
var ar2 = [5,6,7,8]
var ar1 = [1,2,3,4]
var ar2 = [5,6,7,8]
var array = [];
array = [ar1, ar2]
gs.eventQueue('sathwik', current, array, null)
In email script, i have written like below
var t = event.parm1.toString();
template.print(t[0]);
template.print(t[1]);
in notification I am getting output as " 1, that's it.. what is wrong ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-02-2023 08:38 AM - edited 01-02-2023 08:39 AM
Hi,
PFA
var array1 = ['a','b','c'];
var array2 = ['x','y','z'];
var array=[];
array.push(array1);
array.push(array2);
gs.info(array)
gs.info(array[0])
gs.info(array[1])
Thanks and Regards,
Saurabh Gupta