ShakaCode | ShakaCode Blog | Rails On Maui Blog | Rails | ReactJs | JavaScript | Webpack | Productivity |

Lodash retrieve index of the items from array of objects that have a boolean property equal to true


#1

im beginner with lodash i went from c# and i have used LINQ sometimes, i have learned that lodash can be used to do query linq style, but despite my attempts, cant able to get index of the items, from array of objects that have a boolean property equal to true in lodash. Can anyone help me?

My try : var indexofItemns =_.find( arrayOfItmes, (item) => (item.booleanProperty === true)); but i have an array
var indexItems: number[] = [];
indexItems= _.times(arrayOfItmes.length, _.find( arrayOfItmes, (item) => (item.booleanProperty === true));

the second row dont compile neither.

thanks