Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 91a5be7

Browse files
authored
Create array-methods-exercises.js
1 parent 9b7b937 commit 91a5be7

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

assets/array-methods-exercises.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
const flowers = [
2+
{ name: 'tulip', color: 'red' },
3+
{ name: 'dandelion', color: 'yellow' },
4+
{ name: 'rose', color: 'red' },
5+
{ name: 'daisy', color: 'white' },
6+
{ name: 'lily', color: 'white' },
7+
];
8+
9+
// Exercise 1
10+
// use `map` to make the first letter of al flowers a capital.
11+
// so 'tulip' becomes 'Tulip' etc.
12+
13+
// Exercise 2
14+
// use `filter` to get only the flowers with a name of 4 characters
15+
16+
// Exercise 3
17+
// use `reduce` to create an object that contains
18+
// the total number of flowers for each color
19+
20+
// Exercise 4 (bonus)
21+
// use `some` or `every` in combination with another array method
22+
// to find out if all flowers with five letters are red

0 commit comments

Comments
 (0)