-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy patheach_map_practice
More file actions
31 lines (21 loc) · 1.99 KB
/
each_map_practice
File metadata and controls
31 lines (21 loc) · 1.99 KB
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
// # 1. Start with an array of numbers and create a new array with each number times 3.
// # For example, [1, 2, 3] becomes [3, 6, 9]. Use forEach and .map.
// # 2. Start with an array of strings and create a new array with each string upcased.
// # For example, ["hello", "goodbye"] becomes ["HELLO", "GOODBYE"]. Use forEach and .map.
// # 3. Start with an array of hashes and create a new array of string values from each hash's :name key.
// # For example, [{name: "Alice", age: 27}, {name: "Blane", age: 16}] becomes ["Alice", "Blane"]. Use forEach and .map.
// # 4. Start with an array of numbers and create a new array with each number plus 7.
// # For example, [1, 2, 3] becomes [8, 9, 10]. Use forEach and .map.
// # 5. Start with an array of strings and create a new array with each string's length.
// # For example, ["hello", "goodbye"] becomes [5, 7]. Use forEach and .map.
// # 6. Start with an array of hashes and create a new array of number values from each hash's :age key.
// # For example, [{name: "Alice", age: 27}, {name: "Blane", age: 16}] becomes [27, 16]. Use forEach and .map.
// # 7. Start with an array of numbers and create a new array with each number divided by 2.
// # For example, [1, 2, 3] becomes [0.5, 1.0, 1.5]. Use forEach and .map.
// # 8. Start with an array of strings and create a new array with each string's first letter only.
// # For example, ["hello", "goodbye"] becomes ["h", "g"]. Use forEach and .map.
// # 9. Start with an array of hashes and create a new array of number values from each hash's :age key times 2.
// # For example, [{name: "Alice", age: 27}, {name: "Blane", age: 16}] becomes [54, 32]. Use forEach and .map.
// # 10. Start with an array of numbers and create a new array with each number converted into a string.
// # For example, [1, 2, 3] becomes ["1", "2", "3"]. Use forEach and .map.
SOLUTIONS: https://github.com/TaylorOD/Deliberate_Practice-JavaScript/blob/master/solution_key/each_map_practice_solutions.js