能否請你幫我這個代碼是沒有顯示輸出該Java腳本功能無法正常工作
我只想讓他/她的退休 之前一個人離開的年數。 我做了一個已經有值,當我使用了第三個屬性,即,從他們的年齡yearsuntilretire它,應減65,並返回剩下的年齡,然後在退休前
<!DOCTYPE html>
<html>
<head>
<script>
function people(name,age){
this.name= name;
this.age = age;
this.yearsuntilretire = yearsleft();
}
function yearsleft(){
var numyears = 65 - this.age;
return numyears;
}
var sip = new people("manda arpitha",19);
</script>
</head>
<body>
<script type="text/javascript">
document.write(sip.yearsuntilretire();)
</script>
</body>
</html>
this.yearsuntilretire = yearsleft; ...... –
我想你忘記返回爲民()函數。請返回this.yearsuntilretire – WebGuy
分號在一行... –