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
  • 541
  • 6
  • 18
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
  • 10,972
  • 4
  • 14
  • 43