Can someone help me fix my thousandTrees() function, it displaying the console log that i want, but it is also returning undefined on the console.
How do i make the function just do the console log?
this is part of an exercise from a course i am following.
The function is just at the bottom of the code
thank you
// park constructor
class Park {
constructor (name, buildYear, trees, size) {
this.name = name;
this.buildYear = buildYear;
this.trees = trees;
this.size = size;
}
// number of tree / park area
treeDensity() {
return this.trees / this.size;
}
// return the park age
parkAge() {
return new Date().getFullYear() - this.buildYear;
}
}
// street constructor
class Street {
constructor (name, buildYear, size) {
this.name = name;
this.buildYear = buildYear;
this.size = size;
}
};
// all parks
let allParks = [
park1 = new Park("Brighton Park", 1900, 1200, 3),
park2 = new Park("Worthing Park", 1800, 650, 2),
park3 = new Park("Shoreham Park", 1850, 350, 2)
]
// all streets
let allStreets = [
street1 = new Street("Brighton Street", 1858, 2000),
street2 = new Street("Worthing Street", 1950, 1200),
street3 = new Street("Shoreham Street", 1850, 800),
street4 = new Street("Lancing Street", 1980, 760)
];
// calculate the average age of all parks
let parkAgeAvg = function() {
return (park1.parkAge() + park2.parkAge() + park3.parkAge()) / 3
};
// Display the name of the park with more than 1000 trees
let thousandTrees = function() {
for (let cur of allParks) {
if (cur.trees >= 1000) {
console.log(`${cur.name} has more than 1000 trees, we have verified there is actually ${cur.trees} trees in total.`);
}
}
};
// total length of streets and avg length
//size classification of all streets