0👍
Your existing code is nice enough. but one change is your course and time make it unique fields so there will only be one index always so its better to exit early. (you can add false check for not found yourself).
var requiredCourse = (courseDetails)=>courseDetails.course === this.selectedCourse && courseDetails.time === this.selectedTime;
var requiredhorse = (horse)=> horse.name === this.runner;
var courseIndex = data.findIndex(requiredCourse);
var horseOdds = data[courseIndex].data.findIndex(requiredhorse);
console.log(data[courseIndex].data[horseOdds])
But if you have the ability to change the JSON structure. then just directly make the course and time as keys so you can directly access without need for filter or findIndex. hope this make is it little bit cleaner for your liking.
- [Vuejs]-VueJS computed property vs v-if, performance
- [Vuejs]-Custom Bootstrap ES6(module) for switch-toggle button in VU
Source:stackexchange.com