Skip to content

Instantly share code, notes, and snippets.

@valentingavela
Created May 17, 2019 12:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save valentingavela/85cc53ddbc04ee4dac83da12aad6b70f to your computer and use it in GitHub Desktop.
Save valentingavela/85cc53ddbc04ee4dac83da12aad6b70f to your computer and use it in GitHub Desktop.
transform a array in a 2D array
function arrayTo2DArray2(list, howMany) {
var idx = 0
result = []
while (idx < list.length) {
if (idx % howMany === 0) result.push([])
result[result.length - 1].push(list[idx++])
}
return result
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment