Task For MAP Method in Javascript
Task For MAP Method in Javascript
Javascript
Sure! Here are five tasks you can do using the map method in JavaScript:
const users = [
{ id: 1, name: 'Alice' },
{ id: 2, name: 'Bob' },
{ id: 3, name: 'Charlie' }
];
const userNames = users.map(user => user.name);
console.log(userNames); // Output: ['Alice', 'Bob', 'Charl
ie']
These examples demonstrate various ways you can use the map method to
transform elements in an array.