Created
March 10, 2015 23:49
-
-
Save ajnadel/a76dcbd4d9c2f9576d08 to your computer and use it in GitHub Desktop.
This file contains 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.toLinkedList = function(){ | |
var lastElement = {data: this[this.length-1], next: undefined}; | |
for (var i = this.length - 2; i >= 0; i--){ | |
lastElement = {data: this[i], next: lastElement}; | |
} | |
return lastElement; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment