-
Notifications
You must be signed in to change notification settings - Fork 0
started javascript-II #1
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
Conversation
…eep trying before i ask for help
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.
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]) |
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 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) { |
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.
.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()); |
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.
allCaps.push(obj.first_name.toUpperCase()); | |
allCaps = runners.map(obj => obj.first_name.toUpperCase()); |
worked through most of array method.. having some issues with reduce, but want to keep trying.