本文主要是介绍【Edabit 算法 ★☆☆☆☆☆】Convert Hours into Seconds,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
【Edabit 算法 ★☆☆☆☆☆】Convert Hours into Seconds
language_fundamentals
math
numbers
Instructions
Write a function that converts
hours
into seconds.
Examples
howManySeconds(2) // 7200
howManySeconds(10) // 36000
howManySeconds(24) // 86400
Notes
- 60 seconds in a minute, 60 minutes in an hour
- Don’t forget to return your answer.
Solutions
function howManySeconds(hours) {return hours* 60 * 60 ;
}
TestCases
let Test = (function(){return {assertEquals:function(actual,expected){if(actual !== expected){let errorMsg = `actual is ${actual},${expected} is expected`;throw new Error(errorMsg);}}}
})();Test.assertEquals(howManySeconds(2), 7200)
Test.assertEquals(howManySeconds(10), 36000)
Test.assertEquals(howManySeconds(24), 86400)
Test.assertEquals(howManySeconds(36), 129600)
这篇关于【Edabit 算法 ★☆☆☆☆☆】Convert Hours into Seconds的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!