forked from beverlyAH/hofPractice
-
Notifications
You must be signed in to change notification settings - Fork 0
/
practice.js
122 lines (91 loc) · 2.61 KB
/
practice.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
// This repo is optional extra practice to use the underscore functions.
// Here we'll be writing new functions, but these functions will use
// the underscore functions within them.
/*
*
* _.each
*
*/
// use _.each to create a copy of the given array.
var moreFruits = function(fruits) {
var results = [];
_.each(fruits, function(fruit, index, collection) {
results.push(fruit);
});
return results;
};
// use _.each to traverse the number array and determine
// which are multiples of five.
var multiplesOfFive = function(numbers) {
};
/*
*
* _.filter
*
*/
// use _.filter to return the fruits array with only the desired fruit.
var onlyOneFruit = function(fruits, targetFruit) {
};
// use _.filter to return the fruits array with only fruits
// starting with the letter 'P'.
var startsWith = function(fruits, letter) {
};
// return a filtered array containing only cookie-type desserts.
var cookiesOnly = function(desserts) {
};
/*
*
* _.reduce
*
*/
// return the total price of all products.
var sumTotal = function(products) {
};
// return an object consisting of dessert types and how many of each.
// exampleOutput: { dessertType: 3, dessertType2: 1 }
var dessertCategories = function(desserts) {
};
// given an array of movie data objects,return an array containing
// movies that came out between 1990 and 2000.
// TIP: use an array as your accumulator - don't push to an external array!
var ninetiesKid = function(movies) {
};
// return an boolean stating if there exists a movie with a shorter
// runtime than your time limit.
// timeLimit is an integer representing a number of minutes.
var movieNight = function(movies, timeLimit) {
};
/*
*
* _.map
*
*/
// given an array of strings, use _.map to return a new array containing all
// strings converted to uppercase letters.
var upperCaseFruits = function(fruits) {
};
// given an array of dessert objects, return a new array of objects
// that have a new "glutenFree" property, with a boolean value.
// TIP: Items that contain flour are not gluten-free.
var glutenFree = function(desserts) {
};
// use _.map to return an array of items with their sale prices, with a new property
// containing the sale price. round any decimals to 2 places.
//
// having trouble with decimals? check out this article:
// http://adripofjavascript.com/blog/drips/avoiding-problems-with-decimal-math-in-javascript.html
//
/*
example output:
var salePrices = applyCoupon(groceries, 0.20);
[
{
id: 1,
product: 'Olive Oil',
price: '$12.1',
salePrice: '$9.68'
}
];
*/
var applyCoupon = function(groceries, coupon) {
};