Skip to content

Max David Metelus: "mvp- complete" - #454

Open
Mdmetelus wants to merge 2 commits into
bloominstituteoftechnology:masterfrom
Mdmetelus:master
Open

Max David Metelus: "mvp- complete"#454
Mdmetelus wants to merge 2 commits into
bloominstituteoftechnology:masterfrom
Mdmetelus:master

Conversation

@Mdmetelus

Copy link
Copy Markdown

minimum viable product.

@szincone szincone left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

  • Your thought process was right on most of these, just syntax errors for the most part. Interesting and unique ways to solve some of your challenges (like the nickname one)

// 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"] }`);

Copy link
Copy Markdown

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 => element and for loops for (let i=0; i < arr.length; i++). They do the same thing but you can only use one or the other.

Copy link
Copy Markdown

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.

let fullName = [];
runners.foreach(` ${ runners[i]["first_name"] } ${ runners[i]["last_name"] }`);

runners.foreach(fullName.push(runners[i].first_name + " " + runners[i].last_name ));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The inside you made fullName.push(runners[i].first_name + " " + runners[i].last_name is correct if you were trying to do for loops(we weren't trying to do for loops for this assignment though), you just would have to had put it in a for loop like this for (let i = 0; i < runners.length;i++){ fullName.push(runners[i].first_name + " " + runners[i].last_name ) }

// ==== 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" ;});

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

runners.filter((list) => {return list.shirt_size === "L" ;}); could also be written as runners.filter(list => list.shirt_size === "L" ); (you don't need the return statement if it's written on the same line because it's implied. Parentheses are also optional on an arrow function if you're only passing 1 param.

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

  • Checkout the syntax on MDN https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map.
  • Map requires a callback. Should be something like runners.map(items => items.first_name.toUpperCase.concat(items.shirt_size)). (This won't run either because your missing you parentheses on toUpperCase, it should be toUpperCase(). It will work after that though)
  • I would also change items to item or runner since it represents a single runner. (This is a really cool way of using concat to do it, first person I've seen using it)

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