Recap - Arrays Workshop
Part of the Logic & Flow section of Coddy's JavaScript journey — lesson 50 of 65.
Challenge
EasyCreate a function called arrayWorkshop that takes an array of numbers as an argument. The function should perform the following operations:
- Remove all duplicate numbers from the array
- If the array has fewer than 3 elements after removing duplicates, add the number 0 to the array until it has 3 elements
- Replace the first and last elements with their sum
- Return the modified array
Try it yourself
function arrayWorkshop(arr) {
// 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