How do you write empty arrays when they have multiple dimensions? Answer in a comment or in the twitter poll below π
Liquid error: internal
For further actions, you may consider blocking this person and/or reporting abuse
How do you write empty arrays when they have multiple dimensions? Answer in a comment or in the twitter poll below π
Liquid error: internal
For further actions, you may consider blocking this person and/or reporting abuse
Timeless DEV post...
The most used technology by developers is not Javascript.
It's not Python or HTML.
It hardly even gets mentioned in interviews or listed as a pre-requisite for jobs.
I'm talking about Git and version control of course.
Mihai Farcas -
Jesse Warden -
Kerisnarendra -
Al - Naubit -
Once suspended, shiftyp will not be able to comment or publish posts until their suspension is removed.
Once unsuspended, shiftyp will be able to comment and publish posts again.
Once unpublished, all posts by shiftyp will become hidden and only accessible to themselves.
If shiftyp is not suspended, they can still re-publish their posts from their dashboard.
Once unpublished, this post will become invisible to the public and only accessible to Ryan Lynch (he/him).
They can still re-publish the post if they are not suspended.
Thanks for keeping DEV Community π©βπ»π¨βπ» safe. Here is what you can do to flag shiftyp:
Unflagging shiftyp will restore default visibility to their posts.
Top comments (10)
If the challenge/problem specified the cardinality of the sets each of the dimensions span, we could use a recursive function, something like:
Let's say you want that three-dimensional array to be Rubik's cube-like, filled with zeros:
Otherwise, I'd simply go for the solution @wingkwong posted:
[]
π€·ββοΈThe samplist way is :
let myArr = [[],[],[]]
With spread operator:
let arr1 = [[],[]]
let arr2 = [[],...arr1]
We can use it with new Array(3) fill() and map()
I like it. Very empty
Did I get the challenge wrong? It Isn't about creating empty multidimensional array?
It's an interesting challenge. Your answer isn't wrong per-se, as how you represent the empty array depends on the code that processes the value. I think your answer however may show a mix-up between the dimension of an array vs. the length of an array. A multidimensional array is nested according to the number of dimensions. So a two dimensional array with two rows and two columns might look like:
The number of row and columns are the lengths of the arrays in each dimension. A three dimensional array with one element might look like
So when I see an array
[[],[],[]]
I see a two dimensional array, with a length of three in the first dimension. Make sense?Thank you Ryan!!! You teach me something new. i think here in this example: [[],[],[]] it's a 3d array?!
You can tell how many dimensions an array has by how many individual indices you need to access the values. let's add some values to the above array and access one:
Notice that we need two indices to access the values. An array of three dimensions would be nested such that you need three indices. For example:
Thanks so much Ryan, it makes a lot of sense now.