paulgio
paulgio

Reputation: 712

Display array object in Alert

I am trying to display all my array item properties within the Alert screen when a button is pressed. My problem is getting the item properties to be displayed in the alert pop up.

 Alert.alert(
     'Country: ', item.country,
     'Gas: ', item.gasService,
     'Size: ', item.size,

   );

This displays the country correctly but nothing else. I want to display all the items properties in the alert screen but I cannot get it to work at all.

Any help would be great.

Upvotes: 1

Views: 2046

Answers (1)

jshamble
jshamble

Reputation: 491

Use + to concatenate items, and \n to display them on separate lines.

Alert.alert( 'Country: ' + item.country + "\n" + 
     'Gas: ' + item.gasService + "\n" +
     'Size: ' + item.size  + "\n"
   );

Upvotes: 1

Related Questions