I am currently working on a task where I need to search through an array to find specific objects based on their category.
However, when I execute my code, I am only getting one result. In the given example below, there should actually be two results as the cat 2
exists in two of the objects!
Here is the snippet of my code:
var storedArray = [{
"title": "test title 1",
"date_added": "2018-09-26",
"url": "someurl.com",
"filename": "file 1",
"category": "cat 1"
}, {
"title": "test title 2",
"date_added": "2018-10-25",
"url": "someurl.com",
"filename": "file 2",
"category": "cat 2"
},{
"title": "test title 3",
"date_added": "2018-10-25",
"url": "someurl.com",
"filename": "file 3",
"category": "cat 2"
}];
var result = storedArray.find( audio => audio.category === 'cat 2' );
console.log(result);
Can someone help me with this issue? Any advice would be greatly appreciated.