Click here to Skip to main content
15,887,987 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I am trying to learn javascript, and I have the code below. I need to perform calculations with some of my object properties, -find a sum and find the biggest area, for example-. I don't know if I should create an array with my objects (and I don't know how to do this) and then iterate through them. I don't know if this will be the best approach.

class Park{
constructor(name, buildYear, area, noOfTrees){
this.name = name;
this.buildYear = buildYear;
this.area = area;
this.noOfTrees = noOfTrees;
}


const prk1 = new Park('Park1', 1980, 80, 1200);
const prk2 = new Park('Park2', 1972, 180, 2200);
const prk3 = new Park('Park3', 1990, 120, 1600);

Thank you very much for your help.
Andrea

What I have tried:

I have not tried anything yet and I don't know where to start.
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900