Skip to content

Instantly share code, notes, and snippets.

@ironprice91
Created February 18, 2017 05:13
Show Gist options
  • Select an option

  • Save ironprice91/be425d3e192c7ed0c344de029f5a2195 to your computer and use it in GitHub Desktop.

Select an option

Save ironprice91/be425d3e192c7ed0c344de029f5a2195 to your computer and use it in GitHub Desktop.
JS Bin // source https://jsbin.com/siledoyiga
<!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>
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