book

Report

As a team, answer all the questions the team's members submitted on our course forum. Each team member is responsible for one question. But everyone should work together to come up with a good solution. Your answer should consist of Lodash code and a brief writeup. Utilize _.map, _.filter, _.group ...etc. Do not use any for loop.

It is important for everyone to understand all the solutions and make sure you will be able to independently reproduce these solutions when asked to do so. Coming up, we will incorporate variations of these questions into a future hackathon and you are expected to be capable of reproducing and adapting your solutions.

How many courses in IPHY that have 4 credit hours? by Fadhil

var course =_.filter(data, function(n){
  return n['CrsPBADept'] == 'IPHY'
})
var hour = _.filter(course, function(d){
  return d['Hours'] == 4
})

return _.size(hour)

9 courses.

Which departments offer the most 4000 level classes? by Brian

var groups = _.groupBy(data, function(college){
  return college['Subject']
})

var courseLevels = _.mapValues(groups, function(a){
  return _.map(a, function(b){
  return b['Course']
  })
})
var count = 0
var levelCount = _.mapValues(courseLevels, function(level){
  count = 0
  return _.map(level, function(n){
  if(n >= 4000 && n < 5000){
  count++
    }
    return count
  })
})
var result = _.mapValues(levelCount, function(n){
  return _.max(n)
})
return _.pick(result, function(number){
  return number == _.max(result)
})

PSYC 57

Which department has the highest enrollment by Tristan

var groups = _.groupBy(data, function(college){
    return college['Subject']
})
var courseEnroll = _.mapValues(groups, function(a){
    return _.map(a, function(b){
        return b['N']['ENROLL']
    })
})
var enroll = _.mapValues(courseEnroll, function(enrolls){
    return _.sum(enrolls)
})
return _.pick(enroll, function(number){
    return number == _.max(enroll)
})

MATH 8725

What instructor's course has the highest enrollment? by Zhilli

var list = _.map(data, function(course){
  var instructors=course['Instructors']
  var enroll=course['N']['ENROLL']
  var courseName=course['CourseTitle']
  return _.map(instructors, function(instructor){
  return {"instructor": instructor['name'], "courseTitle": courseName, "enrollment": enroll}
  })
})

var maxGroups= _.max(_.flatten(list), function(course){
 return course['enrollment']
})
return maxGroups

The professor is GRAVES, PHILIP E, the course title is Principles of Microeconomics.

What instructor has the highest rating? by Andrew

var list = _.map(data, function(course){
  var instructors=course['Instructors']
  var enroll=course['AvgInstructor']
  return _.map(instructors, function(instructor){
  return {"instructor": instructor['name'], "rating": enroll}
  })
})

var maxGroups= _.max(_.flatten(list), function(course){
 return course['rating']
})
return maxGroups

instructor HOBBS, STEVEN L
rating 6