我正在编写代码来计算直到 65 岁生日的保险费。
到目前为止,我已经想出了这个,但我陷入了困境:
function showQuote(bday,bmonth,byear)
{
var DoB = new Date(byear,bmonth,bday)
var todayDate = new Date();
todayYear = todayDate.getFullYear();
todayMonth = todayDate.getMonth();
todayDay = todayDate.getDate();
var userAge;
userAge = todayYear - byear;
if(todayMonth < (bmonth - 1 ))
{
userAge--;
}
else if (((bmonth - 1) == todayMonth) && (todayDay < bday))
{
userAge--;
}
document.getElementById("ageResult").innerHTML = "You are currently: "
+ userAge;
var displayQuote = 0;
for (Age = userAge; Age <= 65; Age--)
{
displayQuote = 500-(500*(65-Age)/100);
return displayQuote;
}
}
我想做的是显示前 3 年,然后是第 65 年。