const fountainValleyLoopTrail = {
name: 'Fountain Valley Loop',
location: 'Littleton, CO',
distance: 2.3,
traffic: 'moderate',
features: ['bird watching','hiking','cross country skiing','snowshoeing']
}
const emeraldLakeTrail = {
name: 'Emerald Lake',
location: 'Estes Park, CO',
distance: 3.1,
traffic: 'heavy',
features: ['bird watching', 'hiking', 'fishing']
}
Write a function called displayTrailData
that will take in any single object of trail data from above. It should return an array of strings. Passing in fountainValleyLoopTrail
should return:
[
'The trail name: Fountain Valley Loop',
'The trail location: Littleton, CO',
'The trail distance: 2.3',
'The trail traffic: moderate',
'The trail features: bird watching, hiking, cross country skiing, snowshoeing'
];
const favoriteActivities = [
{ name: 'hiking', preferenceLevel: 9 },
{ name: 'fishing', preferenceLevel: 7 },
{ name: 'snowshoeing', preferenceLevel: 0 },
{ name: 'bird watching', preferenceLevel: 6 },
]
Refactor your function so that you can pass in a second parameter of favoriteActivities
. Sort the trail features by preferenceLevel
so that my favorite activites show first. Now when you pass in fountainValleyLoopTrail
and favoriteActivities
, you should return the following, because hiking has the highest preference level.
[
'The trail name: Fountain Valley Loop',
'The trail location: Littleton, CO',
'The trail distance: 2.3',
'The trail traffic: moderate',
'The trail features: hiking, bird watching, snowshoeing'
];
NOTE: What happens if my preference activities and the trail feautures don't match up 100%?
Refactor your function to remove activities that have a 0 preferenceLevel
. Now when you pass in fountainValleyLoopTrail
and favoriteActivities
, you should return the following, because snowshoeing has a preferenceLevel
of 0.
[
'The trail name: Fountain Valley Loop',
'The trail location: Littleton, CO',
'The trail distance: 2.3',
'The trail traffic: moderate',
'The trail features: hiking, bird watching'
];