Jawad Farooqi
Jawad Farooqi

Reputation: 345

JavaScript simple code not running

I'm watching a tutorial and I tried running the following code but it doesn't run.

var person = {
  'address': {
    'street': 'Rose Road',
    'city': 'somewhere',
    'state': 'CA'
  },
  'isfromState': fucntion(state) {
    return (this.address.state === state);
  }
}
console.log(person.isfromState('blah'));

Instead, it gives me this error Exception: SyntaxError: missing } after property list and I can't find the mistake.

Upvotes: 2

Views: 52

Answers (1)

jdmdevdotnet
jdmdevdotnet

Reputation: 1

'isfromState': fucntion(state) { // <--- fucntion isn't a keyword
  return (this.address.state === state);
}

Should be:

'isfromState': function(state) { // <--- use function
  return (this.address.state === state);
}

Upvotes: 3

Related Questions