1

I want to convert this:

[null, 1890, null, NGU]

...into this:

[[], [1890], [], [NGU]]

I've tried creating a new array and pushing values to it, but that just ends up looking the same. Honestly, I'm unsure of what to even call what I'm trying to create. Is it a two-dimensional array or an array of objects?

This is for a google app script and the documentation calls it a two-dimensional array of values.

1
  • This is really a JavaScript question, more than (or as well as) a GAS question, since you would be writing JavaScript in your GAS script to do this. Commented Nov 16, 2021 at 15:38

1 Answer 1

6

var arr = [null, 1890, null, 'NGU']
var arr2d = arr.map(x => [x])

console.log(arr2d) // output --> [ [ null ], [ 1890 ], [ null ], [ 'NGU' ] ]

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.