-4

I'm trying to convert this object into array using jQuery

[["20"],["30"],["45"],["54"],["33"],["15"],["54"],["41"]]

I trying to get an array output like this:

[20,30,45,54,33,15,54,41]

How?

5
  • 2
    Note what you're provided appears to be a multi-dimensional array, which is nothing to do with JSON Commented Dec 1, 2016 at 13:51
  • This isn't even JSON. What you posted is a multi-dimensional array. Commented Dec 1, 2016 at 13:52
  • You can use jsonlint to help insure you have valid JSON Commented Dec 1, 2016 at 13:53
  • @kevinternet I don't understand what you mean? Commented Dec 1, 2016 at 14:04
  • @RoryMcCrossan Sorry it was a mistake. Commented Dec 1, 2016 at 14:07

1 Answer 1

1

Just use map() method to change each array of one string value element into a coresponding number :

var input = [["20"],["30"],["45"],["54"],["33"],["15"],["54"],["41"]];
var result = input.map(x => Number(x[0]));
console.log(result);

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.