Last active
March 1, 2025 17:48
-
-
Save ChinmayMoghe/cbd769863b9cb72fbde57814226a1596 to your computer and use it in GitHub Desktop.
create an 2d array and fill it with something
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Just a utility function I thought of you could use it for some graph problem, or if you are building a board state for minesweeper | |
// or for whatever you need..... | |
function create2DArray(n,fillWith) { | |
return Array.from({length:n},()=>Array.from({length:n},()=>fillWith)); | |
} | |
// Usage create2DArray(2,0) | |
/* | |
[ | |
[0,0], | |
[0,0] | |
] | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment