Recap - Group Friends
Part of the Logic & Flow section of Coddy's JavaScript journey — lesson 41 of 65.
Challenge
EasyCreate 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 groupsexclusiveToFirst: The number of people who are only in the first groupexclusiveToSecond: The number of people who are only in the second grouppotentialConnections: The number of unique connections that could be made between exclusive members of each groupisSubset: 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
1Strings In Depth
String FundamentalsIterate Over StringsTemplate LiteralsString MethodsRecap - String Weaver4JSON Part 2
Iterate Over JSONNested JSONJSON Optional ChainingShallow And Deep CopyRecap - Bicycle ShopRecap - Solar System10Manage Festival System
Project OverviewAdd Movies & Venues2Multi-dimensional Arrays
2D Arrays BasicsAccessing 2D Array ElementsNested Loops with 2D ArraysRecap - 2D ArraysMatrix Addition & SubstractionJagged Arrays3D Arrays And BeyondCommon 2D Array PatternsRecap - All About Arrays5Sets Part 1
What Is A Set?Iterating Over SetsAdding An ElementRemoving An ElementChecking If An Element ExistsSize And Is EmptyCopy And ClearRecap - Basic Of Sets8Arrays Interesting Topics
Array DestructuringSpread Syntax in ArraysSparse ArraysRecap - Arrays Workshop3JSON Part 1
What is a JSON?Check If Key ExistsObject MethodsThe Spread Operator Part 1The Spread Operator Part 2Remove KeysRecap - JSON Manipulate Keys6Sets Part 2
Math - Union Of SetsMath - Intersection Of SetsMath - Difference Of SetsMath - Symmetric DifferenceSubsets And SuperSetsRecap - Group Friends