Complete the code to add an element to the end of the array.
const fruits = ['apple', 'banana']; fruits.[1]('orange'); console.log(fruits);
The push method adds an element to the end of an array.
Complete the code to create a new array with each number doubled.
const numbers = [1, 2, 3]; const doubled = numbers.[1](n => n * 2); console.log(doubled);
The map method creates a new array by applying a function to each element.
Fix the error in the code to find the first number greater than 10.
const nums = [4, 9, 15, 7]; const first = nums.[1](n => n > 10); console.log(first);
The find method returns the first element that matches the condition.
Fill both blanks to create an array of squares for numbers greater than 3.
const nums = [1, 2, 3, 4, 5]; const squares = nums.[1](n => n > 3).[2](n => n * n); console.log(squares);
First, filter selects numbers greater than 3, then map squares them.
Fill all three blanks to create an object counting occurrences of each fruit.
const fruits = ['apple', 'banana', 'apple', 'orange', 'banana', 'apple']; const count = fruits.[1]((acc, fruit) => { acc[[2]] = (acc[[3]] || 0) + 1; return acc; }, {}); console.log(count);
reduce builds an object counting each fruit. The key is the fruit name used twice.
