Menu
Coddy logo textTech

Recap - Group Friends

Part of the Logic & Flow section of Coddy's JavaScript journey — lesson 41 of 65.

challenge icon

Challenge

Easy

Create a function named analyzeFriendGroups that takes two arrays of names (representing two different friend groups) as parameters. The function should convert the arrays to sets and returns an object containing the following information (in this exact order):

  • mutualFriends: The number of people who are in both friend groups
  • exclusiveToFirst: The number of people who are only in the first group
  • exclusiveToSecond: The number of people who are only in the second group
  • potentialConnections: The number of unique connections that could be made between exclusive members of each group 
  • isSubset: Boolean indicating if one group is entirely contained within the other

Try it yourself

function analyzeFriendGroups(group1, group2) {
    let set1 = new Set(group1);
    let set2 = new Set(group2);
    // Write your code here
}

All lessons in Logic & Flow