本文主要是介绍【Edabit 算法 ★☆☆☆☆☆】 Convert Age to Days,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
【Edabit 算法 ★☆☆☆☆☆】 Convert Age to Days
algebra
algorithms
math
Instructions
Create a function that takes the age in years and returns the age in days.
Examples
calcAge(65) // 23725
calcAge(0) // 0
calcAge(20) // 7300
Notes
- Use 365 days as the length of a year for this challenge.
- Ignore leap years and days between last birthday and now.
- Expect only positive integer inputs.
Solutions
function calcAge(age) {return 365*age;
}
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(calcAge(10), 3650)
Test.assertSimilar(calcAge(0), 0)
Test.assertSimilar(calcAge(73), 26645)
这篇关于【Edabit 算法 ★☆☆☆☆☆】 Convert Age to Days的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!