diff --git a/Day 04/Count Objects.js b/Day 04/Count Objects.js index 2f076b8..3cdb86e 100644 --- a/Day 04/Count Objects.js +++ b/Day 04/Count Objects.js @@ -10,3 +10,11 @@ function getCount(objects) { return o.x == o.y; }).length; } +//method 2 +let c=0; +objects.forEach(function(i) { +if(i.x==i.y) + c++; +}) + return c +} diff --git a/Day 04/Create a Rectangle Object.js b/Day 04/Create a Rectangle Object.js index 081efdb..46a7e66 100644 --- a/Day 04/Create a Rectangle Object.js +++ b/Day 04/Create a Rectangle Object.js @@ -8,3 +8,13 @@ function Rectangle(a, b) { this.perimeter = 2 * (a + b); this.area = a * b; } +//method 2 +function Rectangle(a, b) { + const rec={ + length:a, + width:b, + perimeter:2*(a+b), + area:a*b + } + return rec +}