Skip to content

Commit 43a3d0a

Browse files
committed
add messages to console log
1 parent d54653b commit 43a3d0a

2 files changed

Lines changed: 7 additions & 6 deletions

File tree

assignments/array-methods.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ const runnersCopy = [...runners];
462462
runnersCopy.forEach(item =>
463463
fullName.push(`${item.first_name} ${item.last_name}`)
464464
);
465-
// console.log(fullName);
465+
console.log("Fullname:", fullName);
466466

467467
// ==== Challenge 2: Use .map() ====
468468
// 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
@@ -471,19 +471,19 @@ allCaps = runners.map(each => ({
471471
...each,
472472
first_name: each.first_name.toUpperCase()
473473
}));
474-
// console.log(allCaps);
474+
console.log("allcaps", allCaps);
475475

476476
// ==== Challenge 3: Use .filter() ====
477477
// 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
478478
let largeShirts = [];
479479
largeShirts = runners.filter(each => each.shirt_size === "L");
480-
// console.log(largeShirts);
480+
console.log("large-shirts:", largeShirts);
481481

482482
// ==== Challenge 4: Use .reduce() ====
483483
// 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
484484
let ticketPriceTotal = [];
485485
ticketPriceTotal = runners.reduce((acc, each) => (acc += each.donation), 0);
486-
console.log(ticketPriceTotal);
486+
console.log("ticket price total", ticketPriceTotal);
487487

488488
// ==== Challenge 5: Be Creative ====
489489
// Now that you have used .forEach(), .map(), .filter(), and .reduce(). I want you to think of potential problems you could solve given the data set and the 5k fun run theme. Try to create and then solve 3 unique problems using one or many of the array methods listed above.

assignments/closure.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Write a simple closure of your own creation. Keep it simple!
33
function outer(data) {
44
return function inner() {
5+
console.log(data);
56
return data;
67
}
78
}
@@ -33,7 +34,7 @@ const counterFactory = start => {
3334
// Return an object that has two methods called `increment` and `decrement`.
3435
// `increment` should increment a counter variable in closure scope and return it.
3536
// `decrement` should decrement the counter variable and return it.
36-
let count = start;
37+
let count = start || 0;
3738
return {
3839
increment() {
3940
const newCount = count += 1;
@@ -48,7 +49,7 @@ const counterFactory = start => {
4849
}
4950
};
5051

51-
const counterChoice = counterFactory(7);
52+
const counterChoice = counterFactory();
5253

5354
counterChoice.increment();
5455
counterChoice.decrement();

0 commit comments

Comments
 (0)