I created a simple object that has a method to return some calculation but it doesn't work.
I declared the object with its properties and method as in the attached code.
<p id="demo"></p>
<script>
var person = new Object();
person.firstName= "John";
person.lastName= "Doe";
person.age=40;
person.retireAtAge= function (){ return (this.age+25);};
document.getElementById("demo").innerHTML=person.firstName + " Retires at " + person.retireAtAge;
</script>
The expected output is:
John Retires at 65
but I get now is:
John Retires at function (){ return (this.age+25);}