Exercise 1.4: Rest & Spread Operators
Level 1
Exercise 1: Spread
operator in arrays: merge array1
and array2
using spread.
Exercise 2: Rest
operator in functions: create a function that sums an indefinite number of arguments.
Level 2
Exercise 3: Copying objects with spread: Create an object called object1
. Then create a second object, object2
, which is a copy of object1
using the spread operator. Change a property of object2
and check that object1
has not changed.
Exercise 4: Destructuring with rest: Create an array with several elements. Use destructuring and the rest operator to assign the first two elements to variables, and then assign the rest of the elements to a third variable.
Level 3
Exercise 5: Create a function that accepts three arguments. Then, create an array with three elements and call the function using the spread operator with that array.
Exercise 6: Merge objects with spread: create a combined object from two others.
⚠️ Important: Open the browser console (F12 or Ctrl+Shift+I) to see the results of the exercises and verify that they work correctly.