-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Max David Metelus: "mvp- complete" #454
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -54,30 +54,46 @@ const runners = [{"id":1,"first_name":"Charmain","last_name":"Seiler","email":"c | |
| {"id":50,"first_name":"Shell","last_name":"Baine","email":"[email protected]","shirt_size":"M","company_name":"Gabtype","donation":171}]; | ||
|
|
||
| // ==== Challenge 1: Use .forEach() ==== | ||
| // 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. | ||
| // 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. | ||
| let fullName = []; | ||
| runners.foreach(` ${ runners[i]["first_name"] } ${ runners[i]["last_name"] }`); | ||
|
|
||
| runners.foreach(fullName.push(runners[i].first_name + " " + runners[i].last_name )); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The inside you made |
||
|
|
||
| console.log(fullName); | ||
|
|
||
| // ==== Challenge 2: Use .map() ==== | ||
| // 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 | ||
| let allCaps = []; | ||
| console.log(allCaps); | ||
| allCaps = runners.map(function(items) {return items.first_name.toUpperCase();}); | ||
| console.log(allCaps); | ||
|
|
||
| // ==== Challenge 3: Use .filter() ==== | ||
| // 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 | ||
| let largeShirts = []; | ||
| largeShirts = runners.filter((list) => {return list.shirt_size === "L" ;}); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| console.log(largeShirts); | ||
|
|
||
| // ==== Challenge 4: Use .reduce() ==== | ||
| // 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 | ||
| let ticketPriceTotal = []; | ||
| ticketPriceTotal = runners.reduce((total, next) => {return total + next.donation ;}); | ||
| console.log(ticketPriceTotal); | ||
|
|
||
| // ==== Challenge 5: Be Creative ==== | ||
| // 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. | ||
|
|
||
| // Problem 1 | ||
| // Problem 1 - MAKE A NICKNAME FOR EACH CONTESTEANT USING THIER FIRST NAM AND SHIRT SIZE. | ||
| let nickname =[]; | ||
| nickname = runners.map(items.first_name.toUpperCase.concat(items.shirt_size)); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| console.log(nickname); | ||
|
|
||
| // Problem 2 | ||
| // Problem 2 - MAKE A LIST OF THE T DONATIONS IN ORDER OF MOST TO LEAST. | ||
| let best_givers = []; | ||
| best_givers = runners.map(function(items) => {`${items.donation}, ${items.first_name}, ${items.last_name}`}); | ||
| // sort numbers function... | ||
|
|
||
| // Problem 3 | ||
| // Problem 3 - | ||
| let contact_list = []; | ||
| contact_list = runners.map(items.email); | ||
| console.log(contact_list); | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're mixing up forEach
arr.forEach(element => elementand for loopsfor (let i=0; i < arr.length; i++). They do the same thing but you can only use one or the other.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line should have looked something like
runners.forEach( runner => { fullName.push(`${runner.first_name} ${runner.last_name}`); })the forEach just goes through the runners array for us. Then inside you do your action. So now full-name would have our first and last names.