This is my question:
const arr = [];
const Picture = {
PictureDescription1: "this is description 1",
PictureDescription2: "this is description 2",
PictureDescription3: "this is description 3",
PictureUrl1:"https://www.taiwan.net.tw/att/event/8b20ab7e-90e0-49a8-9137-d140fa5d369a.jpg",
PictureUrl2:"https://www.taiwan.net.tw/att/event/7da4b849-11a7-46c8-96fb-412f187ad8bf.jpg",
PictureUrl3:"https://www.taiwan.net.tw/att/event/f04581ce-6b16-46cd-9af3-5661276b9b68.jpg",
}
and I want to make url and descirption to a group and push to a arr. This was my way, but I think it too lengthy:
if(Picture.PictureUrl1) {
arr.push({
url: Picture.PictureUrl1,
description: Picture.PictUrlDescription1
})
}
if(Picture.PictureUrl2) {
arr.push({
url: Picture.PictureUrl2,
description: Picture.PictUrlDescription2
})
}
if(Picture.PictureUrl3) {
arr.push({
url: Picture.PictureUrl3,
description: Picture.PictUrlDescription3
})
}
Is there any ohter way to do this?