Skip to content

Emmanuel tanifum - #1

Merged
jamiegoodnight merged 3 commits into
masterfrom
emmanuel-tanifum
May 8, 2019
Merged

jamiegoodnight merged 3 commits into
masterfrom
emmanuel-tanifum

Conversation

@Manny-Rocks

Copy link
Copy Markdown
Owner

No description provided.

@Manny-Rocks
Manny-Rocks requested a review from jamiegoodnight May 7, 2019 22:27

@jamiegoodnight jamiegoodnight left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yo!

When we run your code for a lot of your array challenges we're getting undefined. I've re-written them for you. You should go over this, compare you code to mine here. See how they're different.

Afterwards, go to repl.it and play around with this practice array:

const test = [{name: "Jamie"}, {name: "Mannnny"}];

https://repl.it/

It's very small, of course, but map over it, use forEach, etc. Remember "map" needs a return value and forEach doesn't. Also, save these answers as a template that you can refer to, archetypes for each of the array methods.

// ==== 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.
// let fullName = [];
// console.log(fullName);

let fullname=runners.forEach(function(x){
console.log(${x.first_name} ${x.last_name});
})

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);

let allCaps=runners.map(function(x){
return x.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 = [];
// console.log(largeShirts);

let largeShirts=runners.filter((x)=>{
return x.shirt_size.includes("L");
})

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 = [];
// console.log(ticketPriceTotal);

let ticketPriceTotal=[]

const tally=runners.reduce(function(currentTotal, currentDonation){
return currentTotal + currentDonation.donation;
}, 0)

ticketPriceTotal.push(tally);

console.log(ticketPriceTotal);

@jamiegoodnight
jamiegoodnight merged commit 24d8f97 into master May 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants