Created
February 18, 2017 05:13
-
-
Save ironprice91/be425d3e192c7ed0c344de029f5a2195 to your computer and use it in GitHub Desktop.
JS Bin // source https://jsbin.com/siledoyiga
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
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <meta charset="utf-8"> | |
| <meta name="viewport" content="width=device-width"> | |
| <title>JS Bin</title> | |
| </head> | |
| <body> | |
| <script id="jsbin-javascript"> | |
| function LinkedList(){ | |
| this.head = null; | |
| } | |
| LinkedList.prototype.push = function(val) { | |
| var current = null, | |
| node = { | |
| val: val, | |
| next: null | |
| }; | |
| if (!this.head) { | |
| this.head = node; | |
| } else { | |
| current = this.head; | |
| while(current.next) { | |
| current = current.next; | |
| } | |
| current.next = node; | |
| } | |
| } | |
| var a = new LinkedList(); | |
| a.push(1); | |
| a.push(2); | |
| a.push(3); | |
| console.log(a.head); | |
| </script> | |
| <script id="jsbin-source-javascript" type="text/javascript">function LinkedList(){ | |
| this.head = null; | |
| } | |
| LinkedList.prototype.push = function(val) { | |
| var current = null, | |
| node = { | |
| val: val, | |
| next: null | |
| }; | |
| if (!this.head) { | |
| this.head = node; | |
| } else { | |
| current = this.head; | |
| while(current.next) { | |
| current = current.next; | |
| } | |
| current.next = node; | |
| } | |
| } | |
| var a = new LinkedList(); | |
| a.push(1); | |
| a.push(2); | |
| a.push(3); | |
| console.log(a.head);</script></body> | |
| </html> |
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 LinkedList(){ | |
| this.head = null; | |
| } | |
| LinkedList.prototype.push = function(val) { | |
| var current = null, | |
| node = { | |
| val: val, | |
| next: null | |
| }; | |
| if (!this.head) { | |
| this.head = node; | |
| } else { | |
| current = this.head; | |
| while(current.next) { | |
| current = current.next; | |
| } | |
| current.next = node; | |
| } | |
| } | |
| var a = new LinkedList(); | |
| a.push(1); | |
| a.push(2); | |
| a.push(3); | |
| console.log(a.head); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment