【Edabit 算法 ★☆☆☆☆☆】 Convert Age to Days
algebra
algorithms
math
Instructions
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)