Skip to content

Instantly share code, notes, and snippets.

@chrisle
Created March 10, 2013 17:06
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 chrisle/5129460 to your computer and use it in GitHub Desktop.
Save chrisle/5129460 to your computer and use it in GitHub Desktop.
Split Array By
/**
* Adds empty elements to an array
*
* @example
* A1: hello
* A2: world
*
* =splitArrayBy(A1:A2, 3)
*/
function splitArrayBy(array, n) {
var result = [];
for (var i = 0; i < array.length; i++) {
result.push(array[i]);
for (var j = 0; j < n; j++) {
result.push([]);
}
}
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment