Revisión OOJS

[Further exercises]–> https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Objects/Object-oriented_JS

the part of the number of elements interests in array I did it all in a loop, instead of separating 1, 2 and then 3 ++ doing it in a loop.

it’s okay?

See the Pen JavaScript orientado a objetos para principiantes 1.0 by lTakisl (@ltakisl) on CodePen.

and

See the Pen OOJS 1 by lTakisl (@ltakisl) on CodePen.

See the Pen OOJS 2 by lTakisl (@ltakisl) on CodePen.

See the Pen OOJS 3 by lTakisl (@ltakisl) on CodePen.

Hello @Takis

you doing great well done

for the further excersice there many way to do it and it’s fine to use your loop but you lost some of the readability of the code specially in the case when there only 2 elements it make me read the case of 2 then for next iteration it will use the first if which could be easier if you used the way in solutions also the solution has better performance i know it so little but as long as your code get bigger even little enhancement would help
in the solution it just write the result for the case of 2 element but for your case you need to loop twice

for

  1. the Perimeter calcPerimeter method change the sides value beside calculated the perimeters you should not change the sides value

  2. same issue as 1 and you did not call the calcPerimeter method

  3. same issue as 1

hope that help and have a nice day :slight_smile:

With the google translation I don’t know what you meant, I didn’t understand you very well, but I modified the

this.sides = * this.sideLength

to

this.sides * this.sideLength

it was that? and I added what was missing I think, tell me if it is correct now :slight_smile:

that exactly what i mean well done :slight_smile:

:grinning: :wink: :+1:

1 Like