How to return only the image_url when few image_url maybe null?
var lineItems = [
{
description: "Packaging",
image_url: null,
...
},
{
description: "T-Shirt",
image_url: <the-url-link>,
...
}
]
In react:
...
lineItems.map(function(line){
if (line.description !== "Packaging") {
var img = line.image_url;
}
console.log(img);
});
...
I keep getting null along with the web links in the console. How to grab only the image_url that has the links. "Packaging" will never have an image_url link; it'll always be null.
filternullvalues away?mapin that way, it's just igrones your condition stackoverflow.com/questions/26716818/…