I am new to javascript and doing a nested find in an array as follow:
var target = this.newRubric.categories
.find((category) => category.name == this.indexTracker.selectedCategory)
.criteria.find(
(criterion) => criterion.name == this.indexTracker.selectedCriterion
)
.descriptors.findIndex(
(descriptor) =>
//Error here, works by removing the curly brackets
{descriptor.name == this.indexTracker.selectedDescriptor}
);
console.log(target);
It always returned -1 which is not found until I removed the curly braces, I know that if there was only one line of code the curly braces is not necessary, but why did adding it will cause an error in the findIndex method?