-
-
Save dtstanley/d9c21a9c217c8ad08b8160fb648c4e23 to your computer and use it in GitHub Desktop.
null created by dtstanley - https://repl.it/Indd/1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); |
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
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.