Skip to content
Advertisement

function to find an element inside the array [closed]

I wrote a function to find an element inside the array. Because the types of arrays are different(ex:Array1,Array1,Array1,Array1), I had a problem with part arr.map(el => el + "." + n), and for my arrays this part must be defined in this way for the function to work.

JavaScript

Friends, can you help me how to solve the problem?

JavaScript

Advertisement

Answer

Based on the code in the question it looks like you really just checking to see if the name exists in the array of objects. You don’t need to return the name from the function because you already know what it is.

You can create a function that passes in the array, the name, and the object property that needs to be evalauted, and then use some to make that evaluation. The function will return a boolean (either true or false).

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement