1

I would like to assign a JSON value to var, however i get the following error.

Error message

var a = { myData.results[count].category[count] }
3
  • 1
    Don't screenshot error messages. Copy/transcribe the text. Commented Mar 24, 2018 at 15:33
  • Cause you dont have a key? Key values stores (objects) need a key and a value Commented Mar 24, 2018 at 15:33
  • Or just drop the curlies, if it is not supposed to be a property. Commented Mar 24, 2018 at 15:34

1 Answer 1

2

Maybe a syntax error, either make it a property of an object:

var a = { prop: myData.results[count].category[count] };

Or just the value:

var a = myData.results[count].category[count];
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.