Skip to content

Instantly share code, notes, and snippets.

@theonlychase theonlychase/arr-subarr
Last active Apr 30, 2019

Embed
What would you like to do?
function matrix(x, y, z) {
return [...Array(x)].map(e => Array(2).fill(z));
}
matrix(3, 2, 3) // [[3, 3], [3, 3], [3, 3]]
const matrix = (x, y, z) =>
Array.from({length: x}, () =>
Array.from({length: y}, () => z)
);
matrix(3, 2, 3) // [[3, 3], [3, 3], [3, 3]]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.