Alright so this one is a lot, and I apologize in advance because I just looked at this today so it might very rough. So I am asking the user for their name, age, and gender. This is put into the Person object, and in it I have my method which is suppose to calculate life expectancy. I then have the myPerson variable of the Person object, which is suppose to take what the user entered and displayed it. Again I just looked at this not to long ago, and gave it my best shot.
Also I have never really understood what this. does, I just used it because thats the way the book has it set up. So if someone can explain that to me I would appreciate it.
First things first. What's the deal with lines 15 though 19? They have nothing to do with the rest of the code of the problem you say you are trying to solve.
Then, please fix your indentation. Indentation is an important and not optional aspect of programming. The current poor indentation hides the structure of the program and makes it hard to follow.
So I have made changes to the code, but still need help with the output. My new person is suppose to take ehat the user entered, and display that. For my last line I give them how long they have left or can expect, so do I have to pass those variables to my new person? Or shouldn't I be able to just to use them? Or does the "this." come into play when trying to get the values of the varaibles? Again im not entirely sure what the .this does I just followed the book
After looking at more samples, and looking closer at the book im certain my output should look like below, but nothing prints out? The myPerson has all the properties of the Person object so there would be no need to try, and pass them. I tried just doing document.write(myPerson.fullName); to see if it prints out, but nothing. So my fullName is not getting a value?
Cody Biggs wrote:Lines 15-19 are just me experimenting with the stuff in the book. It gave the whole list of navigator methods, so I just wanted to try a few.
But it has nothing to do with this question and just muddies the waters. it should not be included in your post.
Cody Biggs wrote:I tried just doing document.write(myPerson.fullName);