-5

I have a string of integers

str = "[7,2,7,7,2,7,7,4,3,2]"

and i want to get an array so that i can manipulate the data easily, but i have no idea how to do it. Can you help me ? I'm sure it's a basic task but i am not very familiar with node.

Thank you.

1
  • 6
    JSON.parse("[7,2,7,7,2,7,7,4,3,2]") Commented May 22, 2017 at 19:53

2 Answers 2

1

Try JSON.parse(yourStr). Alternately:

yourString.substr(1,arr.length-2).split(",").map((el) => { 
  return parseInt(el) 
})
Sign up to request clarification or add additional context in comments.

Comments

0

Looks like JSON, parse it with JSON.parse

numbers = JSON.parse("[7,2,7,7,2,7,7,4,3,2]")

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.