text: Q:
  
  Getting first item in an array with a specific parameter empty
  
  Considering this array : 
  const body = [
    {id: 1,courses: [{title:"course1.1", results:[]}, {title:"course1.2", results:[]}]},
    {id: 2,courses: [{title:"course1.1", results:[]}, {title:"course1.2",results:[]}]},   
  ];
  
  I'm trying to get the first item in body that have a course with no results.
  I tried this : 
  body.filter(session=>session.courses.filter(course=>course.results.length<=0));
  But for a reason that I don't understand it return all items.
  Any helps would be really appreciated, thank you!
  P.S. I already made some try with Array.some and with a simple forEach, with no luck. 
  Edit: I forgot to include my jsfiddle test, https://jsfiddle.net/jonathanlaf/4os0fzv1/
  Edit2: I know that filter will return all results that match, and that's fine, I can just take the first index of the newly returned array. 
  Edit3: I actually expect the newly returned array to look like this : 
  const body2 = [
    {id: 2,courses: [{title:"course1.1", results:[]}, {title:"course1.2",results:[]}]},   
  ];
  
  A:
  
  This should do it:
  
  const body = [ {id: 1,courses: [{title:"course1.1", results:[{title:"result1.1.1"}, {title:"result1.1.2"}]}, {title:"course1.2", results:[]}]}, {id: 2,courses: [{title:"course1.1", results:[]}, {title:"course1.2",results:[]}]}, {id: 3,courses: []}];
  
  console.log(body.reduce((r,c) => (c.courses.length ? r.push({ id: c.id, courses: [...c.courses.filter(({results}) => !results.length)]}) : true) && r, []))
  
  It uses reduce and a filter to get what you need.
  Update: Added handling in the case where courses is just an empty array with no results e.g. {id: 3,courses: []}.
  
  