Hello I wanted to make an json array like below from for loop
{ id: 1, itemName: "USA" },
{ id: 2, itemName: "UK" },
{ id: 3, itemName: "India" },
{ id: 4, itemName: "Canada" },
{ id: 5, itemName: "Germany" },
{ id: 6, itemName: "China" }
I have writen this code for this
data.Countries.forEach(element => {
this.countryInfo.push(
'id:'+i,
'itemName:'+ element.CountryName);
i++;
});
but this not working, please help me for this
data.Countriesarray. There might be better ways to do what you want.