Skip to content

Conversation

Lydster
Copy link
Owner

@Lydster Lydster commented Jan 22, 2019

worked through most of array method.. having some issues with reduce, but want to keep trying.

Copy link
Collaborator

@ch-ance ch-ance left a comment

Choose a reason for hiding this comment

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

Good work! Look at the solution code sent in the channel for some tricks

@@ -56,28 +56,96 @@ const runners = [{"id":1,"first_name":"Charmain","last_name":"Seiler","email":"c
// ==== 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);
runners.forEach(function(obj) {
fullName.push([obj.first_name + obj.last_name])
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is gonna look weird.. "LydiaThornton" vs "Lydia Thornton" for example


// ==== 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);
runners.map(function(obj) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

.map() returns an array, so you don't need to use "push()" here


// ==== 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);
runners.map(function(obj) {
allCaps.push(obj.first_name.toUpperCase());
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
allCaps.push(obj.first_name.toUpperCase());
allCaps = runners.map(obj => obj.first_name.toUpperCase());

@ch-ance ch-ance merged commit ca64bd4 into master Jan 23, 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