Skip to content

Instantly share code, notes, and snippets.

@jaywon
Created December 29, 2014 02:51
Show Gist options
  • Save jaywon/e52984aa60df39b43c6e to your computer and use it in GitHub Desktop.
Save jaywon/e52984aa60df39b43c6e to your computer and use it in GitHub Desktop.
<!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>
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