Skip to content

Commit 9372352

Browse files
committed
Made progress but still having trouble on a few things
1 parent 0d84cbe commit 9372352

3 files changed

Lines changed: 32 additions & 6 deletions

File tree

assignments/array-methods.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,21 +56,36 @@ const runners = [{"id":1,"first_name":"Charmain","last_name":"Seiler","email":"c
5656
// ==== Challenge 1: Use .forEach() ====
5757
// The event director needs both the first and last names of each runner for their running bibs. Combine both the first and last names into a new array called fullName.
5858
let fullName = [];
59+
runners.forEach(function(i){
60+
fullName.push(i.first_name + " " + i.last_name);
61+
});
5962
console.log(fullName);
6063

64+
6165
// ==== Challenge 2: Use .map() ====
6266
// 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
6367
let allCaps = [];
68+
runners.map((caps) =>{
69+
caps.first_name
70+
})
6471
console.log(allCaps);
6572

6673
// ==== Challenge 3: Use .filter() ====
6774
// 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
6875
let largeShirts = [];
76+
runners.filter((shirts,) =>{
77+
shirts.shirt_size==='L';
78+
largeShirts.push(shirts.shirt_size);
79+
});
6980
console.log(largeShirts);
7081

7182
// ==== Challenge 4: Use .reduce() ====
7283
// 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
7384
let ticketPriceTotal = [];
85+
runners.reduce((theReducer,item) =>{
86+
theReducer +=item.donation;
87+
ticketPriceTotal.push(item.donation)
88+
}, 0);
7489
console.log(ticketPriceTotal);
7590

7691
// ==== Challenge 5: Be Creative ====

assignments/callbacks.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
const items = ['Pencil', 'Notebook', 'yo-yo', 'Gum'];
2+
let gru=function(param1, cb){
3+
return cb(param1,param2);
4+
}
25

36
function firstItem(arr, cb) {
47
// firstItem passes the first item of the given array to the callback function.
58
cb(arr[0]);
6-
console.log(cb(arr[0]));
79
}
10+
console.log(items,cb)
811

912
function getLength(arr, cb) {
1013
// getLength passes the length of the array into the callback.

assignments/function-conversion.js

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,31 @@
11
// Take the commented ES5 syntax and convert it to ES6 arrow Syntax
22

33
// let myFunction = function () {};
4+
let noParams=() => {return;}
5+
noParams();
46

57
// let anotherFunction = function (param) {
68
// return param;
79
// };
10+
let oneParam= param => {return param;}
11+
oneParam();
812

913
// let add = function (param1, param2) {
1014
// return param1 + param2;
1115
// };
1216
// add(1,2);
17+
let twoParams= (param1, param2) => param1 + param2;
18+
twoParams(1,2);
1319

14-
let subtract = function (param1, param2) {
15-
return param1 - param2;
16-
};
17-
subtract(1,2); //?
20+
// let subtract = function (param1, param2) {
21+
// return param1 - param2;
22+
// };
23+
// subtract(1,2); //?
24+
let subParams= (param1,param2) => param1 - param2;
25+
subParams(1,2);
1826

1927
exampleArray = [1,2,3,4];
2028
// const triple = exampleArray.map(function (num) {
2129
// return num * 3;
2230
// });
23-
// console.log(triple);
31+
// console.log(triple);

0 commit comments

Comments
 (0)