I am trying to compare a single result to an array of items (Api to be specific). Instead of .find() to return the first result it matches with the Details.title, it returns all the result. I am using EJS:
<%
Movies.find(element => {
if(Details.title === element.text){
console.log(element)
}
})
%>
Movies there is the Array of items (the api). I looped over Movies trying to get a single result that matches with Details.title, but it gives me all the results that match.
What can I do to prevent this?
Array.findneeds to return true on match. I do not see any return value in your code<%Movies.find(element => Details.title === element.text)%>findcorrectly because you have no return value.