Exercise 1.5: Array Transformations
Level 1
Exercise 1: map
: You have an array of numbers [1, 2, 3, 4]. Create a new array containing the square of each number.
Exercise 2: filter
: You have an array of numbers [1, 2, 3, 4]. Create a new array that only contains the even numbers.
Exercise 3: find
: You have an array of numbers [1, 10, 8, 11]. Use the find
function to get the first number greater than 10.
Exercise 4: reduce
: You have an array of numbers [13, 7, 8, 21]. Use the reduce
function to calculate the total sum of the numbers.
Level 2
Exercise 5: Given the array "[1, 3, 7, 10, 15, 17, 11, 5, 8, 12, 9]", create a one-liner function that does the following:
Level 3
Exercise 6: every
and some
: Determine whether all or some of the elements in the array [11, 12, 13, 14] are greater than 10, respectively.
⚠️ Important: Open the browser console (F12 or Ctrl+Shift+I) to see the results of the exercises and verify that they work correctly.