-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflowers.js
46 lines (33 loc) · 818 Bytes
/
flowers.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
const flowers = [
{ id: 1,
color: "white",
species: "white rose",
price: .90,
},
{ id: 2,
color: "blue",
species: "red tulip",
price: 1.10,
}
]
const addFlower = (flowerObject) => {
const lastIndex = flowers.length - 1
const currentLastItem = flowers[lastIndex]
const maxId = currentLastItem.id
const newId = maxId + 1
flowerObject.id = newId
flowers.push(flowerObject)
}
const findExpensiveFlowers = () => {
const expensiveFlowers = []
for (const flower of flowers) {
if(flower.price >= 1){
expensiveFlowers.push(flower)
}
}
return expensiveFlowers // Do not change this code
}
// Do not touch this code
module.exports = {
findExpensiveFlowers, addFlower
}