You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Here we try check to see if the polygon ends where it begins, but because JavaScript compares object/arrays by reference, this comparison will return false even if the points of the head and tail of the polygon do match.
This does not pose a correctness issue, because adding the additional end point redundantly does not change the area of the polygon, but it is a bit wasteful/confusing.
The text was updated successfully, but these errors were encountered:
This actually masks another bug, where if this would not always be false, then the point would not get added, and l variable would not be 1 shorter than the actual length of the array, and the code would access an index outside the array.
https://github.com/math-utils/area-polygon/blob/master/index.js#L7
Here we try check to see if the polygon ends where it begins, but because JavaScript compares object/arrays by reference, this comparison will return false even if the points of the head and tail of the polygon do match.
This does not pose a correctness issue, because adding the additional end point redundantly does not change the area of the polygon, but it is a bit wasteful/confusing.
The text was updated successfully, but these errors were encountered: