Difficulty: Easy
Given an array of numbers, use map() to return a new array where each element is the square of the original.
Example:
Input: [1, 2, 3, 4]
Output: [1, 4, 9, 16]
Difficulty: Easy
Given an array of strings, use map() to return a new array where every string is uppercase.
Example:
Input: ["hello", "world"]
Output: ["HELLO", "WORLD"]
Difficulty: Easy
Given an array of numbers, use map() to return a new array with 10 added to each element.
Example:
Input: [1, 5, 10]
Output: [11, 15, 20]
Difficulty: Easy
Given an array of person objects [{ name: "Alice", age: 25 }, ...], use map() to extract and return just the names.
Example:
Input: [{ name: "Alice", age: 25 }, { name: "Bob", age: 30 }]
Output: ["Alice", "Bob"]
Difficulty: Easy
Given an array of temperatures in Celsius, use map() to convert each to Fahrenheit.
Example:
Input: [0, 100, 37]
Output: [32, 212, 98.6]
Difficulty: Easy
Given an array of numbers, use filter() to return only the even numbers.
Example:
Input: [1, 2, 3, 4, 5, 6]
Output: [2, 4, 6]
Difficulty: Easy
Given an array of numbers, use filter() to return only the odd numbers.
Example:
Input: [1, 2, 3, 4, 5]
Output: [1, 3, 5]
Difficulty: Easy
Given an array of numbers (including negatives), use filter() to return only the positive numbers.
Example:
Input: [-3, 0, 1, -1, 5, 7]
Output: [1, 5, 7]
Difficulty: Easy
Given an array of numbers, use filter() to return only the prime numbers.
Example:
Input: [1, 2, 3, 4, 5, 6, 7]
Output: [2, 3, 5, 7]
Difficulty: Easy
Given an array of strings, use filter() to return only strings whose length is greater than 5.
Example:
Input: ["hi", "hello", "javascript", "js"]
Output: ["hello", "javascript"]
Difficulty: Easy
Given an array of numbers, use reduce() to compute the total sum.
Example:
Input: [1, 2, 3, 4, 5]
Output: 15
Difficulty: Easy
Given an array of numbers, use reduce() to compute the product of all elements.
Example:
Input: [1, 2, 3, 4]
Output: 24
Difficulty: Easy
Given an array of numbers, use reduce() to find the maximum element without using Math.max.
Example:
Input: [3, 7, 1, 9, 4]
Output: 9
Difficulty: Easy
Given an array of numbers, use reduce() to find the minimum element.
Example:
Input: [3, 7, 1, 9, 4]
Output: 1
Difficulty: Easy
Given an array of values, use reduce() to build an object mapping each unique value to its frequency.
Example:
Input: ["a", "b", "a", "c", "b", "a"]
Output: { a: 3, b: 2, c: 1 }
Difficulty: Medium
Given a nested array (one level deep), use reduce() to flatten it into a single array.
Example:
Input: [[1, 2], [3, 4], [5]]
Output: [1, 2, 3, 4, 5]
Difficulty: Medium
Given an array of words, use reduce() to group them into an object keyed by word length.
Example:
Input: ["hi", "hey", "bye", "go", "ok"]
Output: { 2: ["hi", "go", "ok"], 3: ["hey", "bye"] }
Difficulty: Easy
Given an array of numbers, use some() to check if any element is negative. Return true or false.
Example:
Input: [1, 2, -3, 4]
Output: true
Difficulty: Easy
Given an array of numbers, use some() to check if any element is prime.
Example:
Input: [4, 6, 7, 9]
Output: true
Difficulty: Easy
Given an array, use some() to check if any element appears more than once.
Example:
Input: [1, 2, 3, 2]
Output: true
Difficulty: Easy
Given an array, use every() to check if all elements are positive numbers.
Example:
Input: [1, 3, 5, 7] → true
Input: [1, -2, 5] → false
Difficulty: Easy
Given an array, use every() to check if all elements are even.
Example:
Input: [2, 4, 6] → true
Input: [2, 3, 6] → false
Difficulty: Easy
Given an array, use every() to check if every element is of type string.
Example:
Input: ["hello", "world"] → true
Input: ["hello", 42] → false
Difficulty: Easy
Given an array, use find() to return the first even number. Return undefined if none.
Example:
Input: [1, 3, 4, 6]
Output: 4
Difficulty: Easy
Given an array, use find() to return the first negative number.
Example:
Input: [5, 3, -1, -4, 2]
Output: -1
Difficulty: Easy
Given an array of strings, use find() to return the first string that is a palindrome.
Example:
Input: ["hello", "racecar", "level"]
Output: "racecar"