I have this array:
var shareholders = [“name1”, “name2”, “name3”];
This is function from HPSM that is fetching data from that array:
function getShareholders(RECORD)
{
var fShareholder = new SCFile("device");
var rc = fShareholder.doSelect("logical.name=\"" + RECORD + "\"");
if (rc == RC_SUCCESS)
{
print(fShareholder.shareholder_contacts);
return fShareholder.sharholder_contacts;
}
return null;
}
It returns them in array form but I need it to fetch one by one:
var users = new Array();
users[0] = “name1”
users[1] = “name2”
….
I have tried them to loop through for loop but without success.
Are you looking for the map function?
var shareholders = ['name1', 'name2', 'name3'];
var users = shareholders.map(function (user){
return user; // Do transformation here
});
console.log(users);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With