const fountainValleyLoopTrail = {
name: 'Fountain Valley Loop',
location: 'Littleton, CO',
distance: 2.3,
traffic: 'moderate',
features: ['bird watching', 'hiking', 'cross country skiing']
}
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: fishing, hiking, snowshoeing, bird watching'
];
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, fishing, bird watching, snowshoeing'
];
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, fishing, bird watching'
];