Skip to content

Kevin Nguyen's Javascript II pull - #230

Open
Kevnien wants to merge 7 commits into
bloominstituteoftechnology:masterfrom
Kevnien:master
Open

Kevin Nguyen's Javascript II pull#230
Kevnien wants to merge 7 commits into
bloominstituteoftechnology:masterfrom
Kevnien:master

Conversation

@Kevnien

@Kevnien Kevnien commented Aug 7, 2018

Copy link
Copy Markdown

No description provided.

@zackhitch zackhitch 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.

Awesome!

// ==== 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 = [];
runners.forEach(runner => fullName.push({"first_name":runner.first_name, "last_name":runner.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.

This is good! Though you only needed to push the first and last names into the array, I like to see that you're familiar with adding strings as well.

// ==== 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 = [];
let allCaps = runners.map(runner => runner.first_name.toUpperCase());

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

// ==== 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 = [];
let largeShirts = runners.filter(runner => runner.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.

Good! Remember to use ===, (look up the difference between == and ===), and space around the operator.

Comment thread assignments/array-methods.js Outdated
// ==== 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 = [];
ticketPriceTotal.push(runners.reduce((ticketSales, runner) => {return ticketSales+=runner.donation}, 0));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

No need to .push here, simply assign the reduce method to let ticketPriceTotal, such that let ticketPriceTotal = runners.reduce((ticketSales, runner) =>.....

Comment thread assignments/callbacks.js
// multiplyNums multiplies two numbers and passes the result to the callback.
cb(x*y);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

These are all good, but you also should include the invoking of each function, with a callback function that console.logs the result.

Comment thread assignments/closure.js

const name = 'Lyle Dylandy';
function enroll()
{

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 curly brace should be on line 4. This looks like C language style, JS has a few different conventions for code style. Use VS Code with the Prettier extension for automatic formatting on save, this will make your code easier for others (and yourself) to read.

Comment thread assignments/closure.js
console.log(`Hello ${name}, you are now ${codeName}.`);
function sayHi()
{
console.log(`Welcome, ${codeName}, to Celestial Being.`);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

👍

// return param1 + param2;
// };
// add(1,2);
let add = (x, y) => {return x + y};

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Good! When you have it on one line like this, you can also write it as let add = (x, y) => x + y;. When on one line like this you can skip the curly braces {} and the return keyword, as it does that implicitly.
When you use the arrow function on multi lines however you do need the curly braces and return keyword.

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