Max David Metelus: "mvp- complete" - #454
Conversation
| // 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"] }`); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 )); |
There was a problem hiding this comment.
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" ;}); |
There was a problem hiding this comment.
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)); |
There was a problem hiding this comment.
- 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 betoUpperCase(). It will work after that though) - I would also change
itemstoitemorrunnersince it represents a single runner. (This is a really cool way of using concat to do it, first person I've seen using it)
minimum viable product.