There are two arrays in JavaScript named designs and articles.
var designs = [
{
design_id:"bwbmbqlujurv", article_id:14782, name:"adidas demogorgon black"
},
{
design_id:"lg9yba2gkcwr", article_id:14782, name:"harry potter wand"
},
{
design_id:"ztvx3yikkkyx", article_id:5570, name:"hogwarts map"
},
{
design_id:"hlzd4afi9en5", article_id:5570, name:"lannister lion"
},
{
design_id:"sdwererefwff", article_id:14782, name:"pokemon bulbasaur"
},
];
var articles = [
{
article_id:6508, dsn_shared_art_id:null, name:"tee man two sides"
},
{
article_id:13510, dsn_shared_art_id:null, name:"tee woman two sides"
},
{
article_id:5570, dsn_shared_art_id:null, name:"necktie"
},
{
article_id:14782, dsn_shared_art_id:null, name:"sweetwear with hood"
},
]
I am trying to access the value of the first element in the array articles that meets the following conditions:
article => article.article_id == design.article_id || article.dsn_shared_art_id == design.article_id
The .find method is not working as expected:
this.designs.forEach(function(design) {
var $artdata = this.articles.find(article => article.article_id == design.article_id || article.dsn_shared_art_id == design.article_id);
console.log($artdata);//undefined
}.bind(this));
How can I correct this issue?