0

I have a Javascript object:

{
    "answers": "[0,0,0,0,1]"
}

I want to convert the answer string to an array:

var array = [0,0,0,0,1]
deekeh
  • 675
  • 1
  • 6
  • 21
J__
  • 43
  • 4

1 Answers1

1

Use the Json.parse()function for that.

const answers = "[0,0,0,0,1]"
console.log(JSON.parse(answers))
Maik Lowrey
  • 15,957
  • 6
  • 40
  • 79