Skip to content

MVP Reached entirely. #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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 30 additions & 7 deletions assignments/array-methods.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,29 +57,52 @@ const runners = [

// ==== 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 and populate a new array called `fullNames`. This array will contain just strings.
let fullNames = [];
let fullNames = runners.map((runners) => {
return runners.first_name + ' ' + runners.last_name;
});
console.log(fullNames);

// ==== Challenge 2: Use .map() ====
// The event director needs to have all the runners' first names in uppercase because the director BECAME DRUNK WITH POWER. Populate an array called `firstNamesAllCaps`. This array will contain just strings.
let firstNamesAllCaps = [];
let firstNamesAllCaps = runners.map((runners) => {
return runners.first_name.toUpperCase();
});
console.log(firstNamesAllCaps);

// ==== Challenge 3: Use .filter() ====
// The large shirts won't be available for the event due to an ordering issue. We need a filtered version of the runners array, containing only those runners with large sized shirts so they can choose a different size. This will be an array of objects.
let runnersLargeSizeShirt = [];
let runnersLargeSizeShirt = runners.filter((runners) => {
return runners.shirt_size === "L";
});
console.log(runnersLargeSizeShirt);

// ==== Challenge 4: Use .reduce() ====
// The donations need to be tallied up and reported for tax purposes. Add up all the donations and save the total into a ticketPriceTotal variable.
let ticketPriceTotal = 0;
let ticketPriceTotal = runners.reduce((total, runners) => {
return total += runners.donation;
}, 0);
console.log(ticketPriceTotal);

// ==== Challenge 5: Be Creative ====
// Now that you have used .forEach(), .map(), .filter(), and .reduce(). I want you to think of potential problems you could solve given the data set and the 5k fun run theme. Try to create and then solve 3 unique problems using one or many of the array methods listed above.

// Problem 1
// Problem 1: Require emails and their last names for a congratulatory email after the race.

// Problem 2
let mailingList = runners.map((runners) => {
return runners.email + " is the email of " + runners.last_name;
});
console.log(mailingList);

// Problem 3
// Problem 2: DabZ, Livetube, and Quaxo accidentally all have the same colored shirts. Filter the runners who are from these companies so they can choose the right shirt instead of one of the different companies'.

let redShirts = runners.filter((runners) => {
return runners.company_name === "DabZ" || runners.company_name === "Livetube" || runners.company_name === "Quaxo";
});
console.log(redShirts);

// Problem 3: A special letter will be sent out to those who have donated more than 100$. Find out how many of the runners have donated more than 100$.

let specialLetter = runners.reduce((overHundred, runners) => {
return overHundred += (runners.donation >= 100);
}, 0);
console.log(specialLetter);
45 changes: 39 additions & 6 deletions assignments/callbacks.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

const items = ['Pencil', 'Notebook', 'yo-yo', 'Gum'];

/*
/*

// GIVEN THIS PROBLEM:

Expand Down Expand Up @@ -41,29 +41,62 @@ const items = ['Pencil', 'Notebook', 'yo-yo', 'Gum'];

function getLength(arr, cb) {
// getLength passes the length of the array into the callback.
return cb(arr.length);
}

const test1 = getLength(items, length => {
return length
});
console.log(test1);

function last(arr, cb) {
// last passes the last item of the array into the callback.
}
return cb(arr[arr.length - 1]);
};

const test2 = last(items, item => `I love my ${item}!`);
console.log(test2);

function sumNums(x, y, cb) {
// sumNums adds two numbers (x, y) and passes the result to the callback.
}
return cb(x + y);
};

const test3 = sumNums(10, 15, sum => {
return sum;
});
console.log(test3);

function multiplyNums(x, y, cb) {
// multiplyNums multiplies two numbers and passes the result to the callback.
}
return cb(x * y);
};

const test4 = multiplyNums(565, 1000, product => {
return product;
});
console.log(test4);

function contains(item, list, cb) {
// contains checks if an item is present inside of the given array/list.
// Pass true to the callback if it is, otherwise pass false.
}
return cb(list.includes(item));
};

const test5 = contains('Pencil', items, cb => {
return cb
});
console.log(test5);

const test6 = contains('Eraser', items, cb => {
return cb
});
console.log(test6);

/* STRETCH PROBLEM */

function removeDuplicates(array, cb) {
// removeDuplicates removes all duplicate values from the given array.
// Pass the duplicate free array to the callback function.
// Do not mutate the original array.
}
};
10 changes: 10 additions & 0 deletions assignments/closure.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@
// that manipulates variables defined in the outer scope.
// The outer scope can be a parent function, or the top level of the script.

const firstName = 'Anthony';

function voiceMail() {
const middleInitial = 'J.';
const lastName = 'Crowley';
console.log('The name is ' + firstName + ' ' + middleInitial + ' ' + lastName + '. Leave a message, and do it in style.');
};

voiceMail();


/* STRETCH PROBLEMS, Do not attempt until you have completed all previous tasks for today's project files */

Expand Down