Given an array of objects representing people's information, use the map
method to create a new array containing only the names of people.
const people = [
{ id: 1, name: 'Alice', age: 30 },
{ id: 2, name: 'Bob', age: 25 },
{ id: 3, name: 'Charlie', age: 35 },
];
// Expected Output: ['Alice', 'Bob', 'Charlie']
Given an array of products, use the filter
method to create a new array containing only products that are currently in stock.
const products = [
{ id: 1, name: 'Laptop', inStock: true },
{ id: 2, name: 'Phone', inStock: false },
{ id: 3, name: 'Tablet', inStock: true },
{ id: 4, name: 'Headphones', inStock: false },
];
// Expected output: [{ id: 1, name: 'Laptop', inStock: true }, { id: 3, name: 'Tablet', inStock: true }]
Given an array of numbers, use the reduce
method to calculate the total sum of all even numbers in the array.
const numbers = [2, 4, 7, 8, 10, 15];
// Expected Output: 24
- Fork this repository
- Clone forked repository
- Create a new branch
git checkout -b solution
- Create a folder of your nickname
mkdir nickname
- Create files
sol1.js
,sol2.js
, andsol3.js
in your folder - Commit and push your changes
- Create a Pull Request to original repository