Click here to Skip to main content
14,038,727 members
Rate this:
 
Please Sign up or sign in to vote.
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)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Cookies | Terms of Service
Web06 | 2.8.190425.1 | Last Updated 23 Oct 2018
Copyright © CodeProject, 1999-2019
All Rights Reserved.
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100