Menu
Coddy logo textTech

Recap - Arrays Workshop

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

challenge icon

Challenge

Easy

Create a function called arrayWorkshop that takes an array of numbers as an argument. The function should perform the following operations:

  1. Remove all duplicate numbers from the array
  2. If the array has fewer than 3 elements after removing duplicates, add the number 0 to the array until it has 3 elements
  3. Replace the first and last elements with their sum
  4. Return the modified array

Try it yourself

function arrayWorkshop(arr) {
  // Write your code here
}

All lessons in Logic & Flow