Learn Basic JavaScript by Building a Role Playing Game - Step 80

Tell us what’s happening:

I’m not sure what to do anymore. I’ve tried every thing i could and read everything i could and it still will not validate.

Your code so far

<!-- file: index.html -->

/* file: styles.css */

/* file: script.js */
// User Editable Region

const weapons = [
  {
    name: "stick", 
    power = 5
  },
  {
    name: "dagger", 
    power = 30
  },
  { 
    name: "claw hammer", 
    power = 50
  },
  {
    name: "sword", 
    power = 100
  }
];

// User Editable Region

Your browser information:

User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36

Challenge Information:

Learn Basic JavaScript by Building a Role Playing Game - Step 80

Uncaught SyntaxError: Invalid shorthand property initializer

power = 100 is not correct syntax, hence the error, try with column power: 100

what is invalid about it?

That was it. Thank you. could you explain to me why this was more correct? I’ve always thought it needed to be assigned a value because it was going to be an empty variable delcared.

this is valid object declaration

{
name: 'george',
age: 33
}

not

{
name: 'george',
age = 33
}

That’s the way JS works.
Glad it worked.
This things happen all the time untill you get familiar.
Good luck

1 Like

so objects can’t use the assignment operator?

Check this out

1 Like