0

Variable br must consist only of bool values. Which have been gotten by looping through the first array.

state ={
    nonRelated: this.props.non_related.value,
    1:true,
    2:true,
    3:false,
    4:false,
    5:true,
   //  etc.
}

let ar = [1,2,3,4,5,6,....20];
let br = ar.map(el => {
return state.el
})

Another example: practical example

I need to filter the array, if the key in the iteratee (which is an object) in the state has the value "true".

4
  • 1
    state[el] not state.el. Also .forEach() doesn't pay attention to the return value of the callback function. You probably want .filter(). Commented Feb 6, 2019 at 14:26
  • I think you meant map not forEach Commented Feb 6, 2019 at 14:27
  • Yes, but it doesn't make much difference :) Commented Feb 6, 2019 at 14:28
  • @Pointy yes, in my actual code it's .filter(), which is in the photo. Commented Feb 6, 2019 at 14:29

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.