Last active
August 29, 2015 14:04
-
-
Save yahyaKacem/041eef00e53028b1598f to your computer and use it in GitHub Desktop.
make equal rows from a list
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function () { | |
inputList = [0, 1, 2, 3, 4, 5, 6, 7, 8]; | |
ouputList = []; | |
makeRowsFromList = function makeRowsF(inputList, outputList, colsNum) { | |
var i, len; | |
outputList = outputList || []; | |
len = inputList.length; | |
for (i = 0; i < len; i += colsNum) { | |
outputList.push(inputList.slice(i, i + colsNum)); | |
} | |
}; | |
makeRowsFromList(intputList, outputList, 3); | |
}()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Make equal rows from a list
just a simple function that takes a list like this:
And turn it into a list like this:
I made this to be used as a methode to group a list into equaly devided rows to be used with
bootstrap Grid system and AngularJS ngRepeat directive.