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年を表示することです。