JavaScript程序应该打印你退休多少年

时间:2014-03-25 18:19:56

标签: javascript-objects

我编写了一个javaScript程序,该程序会给你多少年的时间,直到退休,但正如预期的那样它不起作用,有人可以帮我搞清楚吗?

<html>

        // 27:

    function people( name1 , age1){
        this.name1 = name1;
        this.age1 = age1;
        this.yearsUntilRetaire = yearsLeft;
    }

    var gali1 = new people ("gali papini" , 14);
    var jack = new people ("jhon smith" , 17);

    function yearsLeft(){
    var retYears = 65 - this.age;
    return retYears;
    }
</script

//27:
document.write("<br /> " + gali.yearsUntilRetaire());
</script>

1 个答案:

答案 0 :(得分:0)

一些问题只是错别字:

gali1.yearsUntilRetaire();


var retYears = 65 - this.age1;

但它应该适合你

http://jsfiddle.net/AXy9K/