-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflowers.js
65 lines (44 loc) · 1.18 KB
/
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
const flowers = [
{
id: 1,
color: "white",
species: "rose",
price: ".90"
},
{
id: 2,
color: "red",
species: "tulip",
price: "1.10"
}]
const addFlower = (flowerObject) => {
const lastIndex = flowers.length - 1
const currentLastFlower = flowers[lastIndex]
const maxId = currentLastFlower.id
const idForNewFlower = maxId + 1
flowerObject.id = idForNewFlower
flowers.push(flowerObject)
}
addFlower(flowers)
// console.log(flowers)
const findExpensiveFlowers = () => {
const expensiveFlowers = []
for (const flower of flowers) {
const affordableFlower = 1
if (flower.price >= affordableFlower) {
expensiveFlowers.push(flower)
}
}
return expensiveFlowers // Do not change this code
}
console.log(findExpensiveFlowers)
// /*
// Write a for..of loop that iterate the array
// of flowers, and if the price of a flower is
// greater than or equal to 1.00, it should be
// added to the `expensiveFlowers` array.
// */
// Do not touch this code
module.exports = {
findExpensiveFlowers, addFlower
}