本文主要是介绍0055【Edabit ★☆☆☆☆☆】【弧度转角度】Radians to Degrees,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
0055【Edabit ★☆☆☆☆☆】【弧度转角度】Radians to Degrees
logic
math
numbers
Instructions
Create a function that takes an angle in radians and returns the corresponding angle in degrees.
Examples
radiansToDegrees(1) // 57.29577951308232
radiansToDegrees(20) // 1145.9155902616465
radiansToDegrees(50) // 2864.7889756541163
Notes
- N/A
Solutions
function radiansToDegrees(rad) {return rad*180/Math.PI;
}
TestCases
let Test = (function(){return {assertEquals:function(actual,expected){if(actual !== expected){let errorMsg = `actual is ${actual},${expected} is expected`;throw new Error(errorMsg);}},assertSimilar:function(actual,expected){if(actual.length != expected.length){throw new Error(`length is not equals, ${actual},${expected}`);}for(let a of actual){if(!expected.includes(a)){throw new Error(`missing ${a}`);}}}}
})();Test.assertEquals(radiansToDegrees(1), 57.29577951308232)
Test.assertEquals(radiansToDegrees(5), 286.4788975654116)
Test.assertEquals(radiansToDegrees(7), 401.07045659157626)
Test.assertEquals(radiansToDegrees(100), 5729.5779513082325)
Test.assertEquals(radiansToDegrees(180), 10313.240312354817)
这篇关于0055【Edabit ★☆☆☆☆☆】【弧度转角度】Radians to Degrees的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!