-
Notifications
You must be signed in to change notification settings - Fork 0
/
Day 17
47 lines (37 loc) · 894 Bytes
/
Day 17
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
DAY 17
Instructions
(This challenge is worth 5 points)
Your task is to write a function that will take in an array of toggle objects and a specific toggle name. The goal is to switch only the specific toggle, without affecting the other toggles and then return the updated array.
Don't forget that you can use your previous function from the fourth challenge to help you complete it faster!
Examples
Input:
const toggleList = [
{
name: "toggleA",
isOn: false
},
{
name: "toggleB",
isOn: true
}
]
const specificToggle = "toggleA"
Output:
[
{
name: "toggleA",
isOn: true
},
{
name: "toggleB",
isOn: true
}
]
SOLUTION
const switchSpecificToggle = (toggleList, specificToggle) =>{
for (let i in toggleList){
if (toggleList[i].name === specificToggle){
toggleList[i].isOn = !toggleList[i].isOn}
}
return toggleList
}