I know there are a lot of examples out there, but still I can't get it working. I have a JSON like this:
{"domiciles":[{"country":"AF"},{"country":"AX"},{"country":"AL"}],"investor":[{"type":"ii"},{"type":"pi"}]}
stored in sessionStorage.getItem("profile");
How can I convert in two comma seperated strings? Like ...
AF,AX,AL
ii,pi
Failed attempts:
var dataResidence = sessionStorage.getItem("profile");
var resultResidence = dataResidence.map(function(val) {
return val.country;
}).join(',');
console.log(resultResidence);
Or:
var newString = "";
for(var i=0; i< dataResidence.domiciles.length;i++){
newString += userDefinedSeries.country[i];
newString += ",";
}
console.log(newString);