Skip to content

Commit 01ba552

Browse files
committed
finshed closure
1 parent a0401da commit 01ba552

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

assignments/array-methods.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,16 +64,27 @@ console.log(fullName);
6464
// ==== Challenge 2: Use .map() ====
6565
// 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
6666
let allCaps = [];
67+
allCaps = runners.map(function(item){
68+
return item.first_name.toUpperCase();
69+
});
6770
console.log(allCaps);
6871

6972
// ==== Challenge 3: Use .filter() ====
7073
// 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
7174
let largeShirts = [];
75+
largeShirts = runners.filter(function(item){
76+
if(item.shirt_size === 'L') {
77+
return item;
78+
}
79+
})
7280
console.log(largeShirts);
81+
{
7382

83+
}
7484
// ==== Challenge 4: Use .reduce() ====
7585
// 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
7686
let ticketPriceTotal = [];
87+
ticketPriceTotal = runners.reduce((acc, item) => acc + item.donation, 0)
7788
console.log(ticketPriceTotal);
7889

7990
// ==== Challenge 5: Be Creative ====

assignments/closure.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
// ==== Challenge 1: Write your own closure ====
2-
// Write a simple closure of your own creation. Keep it simple!
2+
// Write a simple closure of your own creation. Keep it simple
3+
function musicInterest (){
4+
let name = 'Deshauna';
5+
let artist = 'Miguel';
6+
function statement() {
7+
console.log(`${name} loves her some ${artist}!`);
8+
}
9+
return statement;
10+
}
11+
12+
let musicInterestStatement = musicInterest();
13+
musicInterestStatement();
14+
315

416

517
/* STRETCH PROBLEMS, Do not attempt until you have completed all previous tasks for today's project files */

0 commit comments

Comments
 (0)