Skip to content

Instantly share code, notes, and snippets.

@chrisle chrisle/gist:5129460
Created Mar 10, 2013

Embed
What would you like to do?
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
You can’t perform that action at this time.