const gear = {
camping: [
{
item: 'tent',
condition: 'good'
},
{
item: 'sleeping bag',
condition: 'bad'
},
{
item: 'flashlight',
condition: 'excellent'
}
],
climbing: [
{
item: 'climbing shoes',
condition: 'bad'
},
{
item: 'harness',
condition: 'good'
}
],
kayaking: [
{
item: 'kayak',
condition: 'okay'
},
{
item: 'life jacket',
condition: 'excellent'
},
{
item: 'dry bag',
condition: 'bad'
}
]
};
Write a function that will return an array of all items that are in bad condition.
['sleeping bag', 'climbing shoes', 'dry bag' ]
Refactor your function so that we can keep track of which activity the bad condition item is associated with.
[
{ camping: 'sleeping bag' },
{ climbing: 'climbing shoes' },
{ kayaking: 'dry bag' }
]
Refactor your function so that the gear is organized by condition.
{
good: [
{ item: 'tent', activity: 'camping' },
{ item: 'harness', activity: 'climbing' }
],
bad: [
{ item: 'sleeping bag', activity: 'camping' },
{ item: 'climbing shoes', activity: 'climbing' },
{ item: 'dry bag', activity: 'kayaking' }
],
excellent: [
{ item: 'flashlight', activity: 'camping' },
{ item: 'life jacket', activity: 'kayaking' }
],
okay: [ { item: 'kayak', activity: 'kayaking' } ]
}