Skip to content

Instantly share code, notes, and snippets.

View LeoAJ's full-sized avatar
:octocat:

Leo Hsieh LeoAJ

:octocat:
  • Bay Area, CA
View GitHub Profile
@LeoAJ
LeoAJ / matrix.js
Last active November 28, 2016 17:26
Generate `n` dimensional matrix
/**
* n = 3, offset = 1
* [
* [1, 2, 3],
* [4, 5, 6],
* [7, 8, 9]
* ]
*/
const createMatrix = (n, offset = 0) => Array.from(
{ length: n }, (v1, i1) => Array.from(