Last active
May 25, 2018 07:08
-
-
Save joshuakemmerling/a1e957feeeff17d7db2e0bbed124396e to your computer and use it in GitHub Desktop.
JavaScript transpose(). Like Ruby transpose.
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
Array.prototype.transpose = function () { | |
return this.length === 0 ? this : this[0].map((col, i) => this.map((row) => row[i])) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment