You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: assignments/array-methods.js
+11Lines changed: 11 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -64,16 +64,27 @@ console.log(fullName);
64
64
// ==== Challenge 2: Use .map() ====
65
65
// The event director needs to have all the runner's first names converted to uppercase because the director BECAME DRUNK WITH POWER. Convert each first name into all caps and log the result
66
66
letallCaps=[];
67
+
allCaps=runners.map(function(item){
68
+
returnitem.first_name.toUpperCase();
69
+
});
67
70
console.log(allCaps);
68
71
69
72
// ==== Challenge 3: Use .filter() ====
70
73
// The large shirts won't be available for the event due to an ordering issue. Get a list of runners with large sized shirts so they can choose a different size. Return an array named largeShirts that contains information about the runners that have a shirt size of L and log the result
71
74
letlargeShirts=[];
75
+
largeShirts=runners.filter(function(item){
76
+
if(item.shirt_size==='L'){
77
+
returnitem;
78
+
}
79
+
})
72
80
console.log(largeShirts);
81
+
{
73
82
83
+
}
74
84
// ==== Challenge 4: Use .reduce() ====
75
85
// The donations need to be tallied up and reported for tax purposes. Add up all the donations into a ticketPriceTotal array and log the result
0 commit comments