loading...

Discussion on: Daily Challenge #84 - Third Angle of a Triangle

Collapse
kvharish profile image
K.V.Harish

My solution in js

const thirdAngle = (angle1, angle2) => (angle1 && angle2 && (angle3 = 180 - (angle1 + angle2)) > 0) ? angle3 : 'Invalid - Sum of all angles of a triangle should be 180 degrees';
Collapse
thepeoplesbourgeois profile image
Josh

What happens if I enter thirdAngle(0,0)?

Collapse
kvharish profile image
K.V.Harish

Good catch. Edited. But the challenge is to deal with positive integers so didn't take 0 into account as it is neither positive nor negative integer.

Thread Thread
thepeoplesbourgeois profile image
Josh

True enough. But why code purely for specs when coding for the edge and error cases takes just a few more minutes?