A
A
Alex Polyakh2018-03-03 20:10:32
JavaScript
Alex Polyakh, 2018-03-03 20:10:32

Return the key of the object, in the array of which a match was found with the error that was passed, what am I doing wrong?

There is an object:

const obj = {
  defaultError: ['A1', 'A2'],
  redirect: ['B1', 'B2']
}

Iterate through each value and if there is an entry in the array that is equal to an error, return that key (defaultError)
Source code: https://stackblitz.com/edit/react-i6kvzk

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2018-03-03
@PolyakhAleksandr

Wow, you're not the only one today who doesn't know that forEach doesn't return anything.
Rewrite your code so that it works as it should , for example.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question