score:0

The Idea is to do something like this. Create a helper function to restructure the data into a multidimensional array by grouping them so that each array in the multidimensional array holds records about courses with the same id. then loop through the multidimensional array and perform whatever logic you want to.

let courses=[{id:1, SUBJECT: "ACC", NO:121,DESCR: 'class description1'}, 
         {id:2, SUBJECT:"ACC", NO:121, DESCR:'class description2'},
        ...]  


//Where ever we want to print the first group we just need to call the CourseList with a single input from the multidimentional structured array asonst 

CourseList=(courses, onCourseSelect)=>{
//create another variable to hold the structured data
//this ensures that each key in the array is it self another array holding all the courses with that same id.
let structuredData = new Array();
 courses.map(course =>  structuredData[course.id] = (courses.filter(co =>(co.id == course.id ))))
  <div className="List ui relaxed divided list">
    structuredData.map((data, k) => {
      //each iteration over data is printing for a single group
      console.log("Group", k)
      data.map(course=>
        <CourseItem key={course.id} descr={course.DESCR} onCourseSelect={onCourseSelect}  />
      )
    })
 </div>
}


Related Query

More Query from same tag