Javascript 计算圆的完整圈数

Javascript 计算圆的完整圈数,javascript,Javascript,我被这个家庭作业问题难住了 我不知道怎么数到360度以外。我得到了4组90度、368度、809度和2500度作为参数 function calculateFullTurns(degrees) { // return the number of full turns you can make with the provided degrees // 1 full turn === 360 degrees 您可以使用reduce()获得所有参数的总和,然后除以360。还可以在结果上

我被这个家庭作业问题难住了

我不知道怎么数到360度以外。我得到了4组90度、368度、809度和2500度作为参数

function calculateFullTurns(degrees) {
    // return the number of full turns you can make with the provided degrees
    // 1 full turn === 360 degrees

您可以使用
reduce()
获得所有参数的总和,然后除以
360
。还可以在结果上使用
Math.floor()
,因为您需要整圈

函数满转(…args){
返回数学地板(参数减少((ac,a)=>ac+a,0)/360)
}

console.log(fullTurns(903688092500))
您尝试过对数字进行除法吗?因为它使用ES6语法,所以可能无法在所有情况下使用browsers@Faizan谢谢,但OP没有提到任何地方不使用ES6或在所有的环境中工作browsers@Faizan目前,92%的用户支持ES6,除非您专门针对IE 11,没有理由不使用它。