1let users = [
2 {firstName : "Susan", lastName: "Steward"},
3 {firstName : "Daniel", lastName: "Longbottom"},
4 {firstName : "Jacob", lastName: "Black"}
5];
6
7let userFullnames = users.map(function(element){
8 return `${element.firstName} ${element.lastName}`;
9})
10
11console.log(userFullnames);
12// ["Susan Steward", "Daniel Longbottom", "Jacob Black"]
1let arr = [3, 4, 5, 6];
2
3let modifiedArr = arr.map(function(element){
4 return element *3;
5});
6
7console.log(modifiedArr); // [9, 12, 15, 18]
1let arr = [3, 4, 5, 6];
2
3for (let i = 0; i < arr.length; i++){
4 arr[i] = arr[i] * 3;
5}
6
7console.log(arr); // [9, 12, 15, 18]