Created
December 29, 2014 02:51
-
-
Save jaywon/e52984aa60df39b43c6e to your computer and use it in GitHub Desktop.
// source http://jsbin.com/cinugi
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<script id="jsbin-javascript"> | |
function List(){ | |
this.start=null; | |
this.end=null; | |
List.makeNode = function(){ | |
return {data: null, next: null}; | |
} | |
this.add = function(data) { | |
if(this.start === null){ | |
this.start = List.makeNode(); | |
this.end = this.start; | |
}else{ | |
this.end.next = List.makeNode(); | |
this.end = this.end.next; | |
} | |
this.end.data = data; | |
} | |
} | |
var list = new List(); | |
for(var i=1; i<=10; i++){ | |
list.add(i); | |
} | |
console.log(list); | |
</script> | |
<script id="jsbin-source-javascript" type="text/javascript">function List(){ | |
this.start=null; | |
this.end=null; | |
List.makeNode = function(){ | |
return {data: null, next: null}; | |
} | |
this.add = function(data) { | |
if(this.start === null){ | |
this.start = List.makeNode(); | |
this.end = this.start; | |
}else{ | |
this.end.next = List.makeNode(); | |
this.end = this.end.next; | |
} | |
this.end.data = data; | |
} | |
} | |
var list = new List(); | |
for(var i=1; i<=10; i++){ | |
list.add(i); | |
} | |
console.log(list); | |
</script></body> | |
</html> |
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
function List(){ | |
this.start=null; | |
this.end=null; | |
List.makeNode = function(){ | |
return {data: null, next: null}; | |
} | |
this.add = function(data) { | |
if(this.start === null){ | |
this.start = List.makeNode(); | |
this.end = this.start; | |
}else{ | |
this.end.next = List.makeNode(); | |
this.end = this.end.next; | |
} | |
this.end.data = data; | |
} | |
} | |
var list = new List(); | |
for(var i=1; i<=10; i++){ | |
list.add(i); | |
} | |
console.log(list); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment