You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
11 lines
321 B
11 lines
321 B
const map = (array, operation) => {
|
|
let arrayOfMappedItems = [];
|
|
for (let item of array) {
|
|
arrayOfMappedItems.push(operation(item));
|
|
}
|
|
return arrayOfMappedItems;
|
|
};
|
|
|
|
console.log(map([{ name: 'john', role: 'author'}, { name: 'jane', role: 'owner'}], user => user.name));
|
|
|
|
module.exports = { map };
|