【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)