Skip to content

Instantly share code, notes, and snippets.

@kaylagordon
Last active May 29, 2023 15:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kaylagordon/dbac8b36ef71b40f72a86a4ac775546b to your computer and use it in GitHub Desktop.
Save kaylagordon/dbac8b36ef71b40f72a86a4ac775546b to your computer and use it in GitHub Desktop.

Universities

const universities = {
  osu: {
    name: 'Ohio State University',
    location: 'Columbus, Ohio',
    majors: ['business', 'biology', 'psychology', 'marketing', 'computer science'],
    graduationRate: 0.82,
    enrollment: 61369
  },
  csu: {
    name: 'Colorado State University',
    location: 'Fort Collins, Colorado',
    majors: ['business', 'human development', 'psychology', 'kinesiology', 'mechanical engineering'],
    graduationRate: 0.71,
    enrollment: 33413
  },
  ucsb: {
    name: 'University of California, Santa Barbara',
    location: 'Santa Barbara, California',
    majors: ['sociology', 'business', 'communication', 'psycology', 'biology'],
    graduationRate: 0.85,
    enrollment: 24346
  }
};

Level One

Write a function that finds the total enrollment for ALL students in ALL unversities
(Hint: You DO need Object.keys() for this one - why??)

findTotalEnrollment() 
// -->  119,128

Level Two

Write a function that takes a parameter of a school code and returns that school's enrollment
(Hint: You DO NOT need Object.keys() for this one - why??)

findSchoolEnrollment('osu')
// 'Ohio State University has 61369 students.'

findSchoolEnrollment('ucsb')
// 'University of California, Santa Barbara has 24346 students.'

Level Three

Write a function that takes a parameter of major and returns a list of school names that have that major

findSchoolByMajor('biology') 
// -->  ['Ohio State University', 'University of California, Santa Barbara']

findSchoolByMajor('business') 
// -->  ['Ohio State University', 'Colorado State University', 'University of California, Santa Barbara']

Level Four (🌶)

Write a function that takes a parameter of 'enrollment' or 'graduationRate' and returns the name of the school with the highest value in the given category

findHighestByCategory('enrollment') 
// --> 'Ohio State University'

findHighestByCategory('graduationRate') 
// --> 'University of California, Santa Barbara'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment