Challenges

↳ Angle Difference

Intro to Programming

diff.js

Create a function diff that accepts two angles (as integer numbers), each between 0 and 360, and returns the smallest difference between them.

For example:

diff(0, 45) === 45;         // not 315, but 45, because 45 is smaller
diff(0, 180) === 180;
diff(0, 190) === 170;       // not 190, but 170, because 170 is smaller
diff(120, 280) === 160;
Start challenge Successful completion: 90%

Last code review

User Updated at Submissions count
krivtsov 09 Mar 09:41 1