Question: I am getting results from rest service into one string, it contain a number(id) or multiple number(multiple id) seprated by commas.

Now i want to pass above id or multiple id into function as a parameter so it returns me rolename, so how can i pass multiple id to functionin javascript....Kindly help as i am new to programming

```
var roleNamedata = 'javascript=xdmp.roleName(' + '"' + id+ '"' + ')'; 

```

how can i pass array to above function, and how to convert string into array

Answer: 
the following code will help u to convert a comma separated string into an array,

```
var string = "1,2,3,4,5";
var array = string.split(","); // string to array conversion
function takesArray(a) { // taking an array as parameter
    console.log(a);
}
takesArray(array); // passing array as argument

```
use [Array.forEach](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach) 

```
var a = ['a', 'b', 'c'];

a.forEach(function(element) {
    console.log(element);
});

// a
// b
// c

```

or [Array.map](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/map)
 var a = ['a', 'b', 'c'];

```
a.map(function(element) {
    console.log(element);
});

// a
// b
// c

```

console.log() will print value into developers tools console (on chrome hit F12)