-
Notifications
You must be signed in to change notification settings - Fork 0
/
Day 14
44 lines (38 loc) · 888 Bytes
/
Day 14
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
DAY 14
Instructions
(This challenge is worth 10 points)
Your task is to write a function that will take in an array of objects containing switches. The function will change the value of the isOn property to true for every switch in the list, and then return the updated array.
You can use the previous switchToggle function from the fourth challenge, however be careful, since we want all of them on, not toggled!
Examples
Input:
const toggleList = [
{
name:"Air",
isOn:true
},
{
name:"Radio",
isOn:false
},
]
Output:
[
{
name:"Air",
isOn:true
},
{
name:"Radio",
isOn:true
},
]
SOLUTION
const switchAllTogglesOn = (toggleList) => {
//itirating through the array list to find isOn set to false
for (let i of toggleList){
if (i.isOn === false){
//when found, setting it to true
i.isOn = true}
//returning updated toggleList
} return toggleList
}