Skip to content

Instantly share code, notes, and snippets.

@dtstanley
Forked from anonymous/Indd-1.js
Created June 15, 2017 21:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dtstanley/d9c21a9c217c8ad08b8160fb648c4e23 to your computer and use it in GitHub Desktop.
Save dtstanley/d9c21a9c217c8ad08b8160fb648c4e23 to your computer and use it in GitHub Desktop.
null created by dtstanley - https://repl.it/Indd/1
var person ={
name: ['Bob', 'Smith'],
age:32,
gender:'male',
interests: ['music','skiing'],
bio: function(){
alert(this.name[0] + ' ' +this.name[1] + ' is ' + this.age + ' years old. He likes ' + this.interests[0] + ' and ' + this.interests[1] + '.');
},
greeting: function(){
alert('Hi! I\'m ' + this.name[0] + '.');
}
};
person.name[0] = ['Stephens'];
person.age= [44];
person.interests[1]=['the bible'];
person.bio();
person.greeting();
@dtstanley
Copy link
Author

I just worked with this example in an article because I did not understand three of the last 5 lines they included. I modified them for my own testing. Why didn't - person.name[0]:'Stephens'; - work? Assignment must use = sign.

@dtstanley
Copy link
Author

Also, person.age is identifying an array of 44 items or the 44th item. The correct statement should be person.age = 44;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment