Recap - Basic Of Sets
Part of the Logic & Flow section of Coddy's JavaScript journey — lesson 35 of 65.
Challenge
EasyCreate a function called processStudentGroups that takes an array of student names as an argument. The function should:
- Create a Set from the input array to get unique student names
- Remove any student whose name starts with 'Z' (case insensitive)
- Add 'John Doe' to the Set if not already present
- Return an object with the following properties:
uniqueCount: The number of unique studentshasJohnDoe: A boolean indicating whether 'John Doe' is in the SetstudentsArray: An array of the final set of student names
Try it yourself
function processStudentGroups(students) {
// 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 Keys