# Javascript code HELP!

**URL:** https://forum.kirupa.com/t/javascript-code-help/329198
**Category:** Uncategorized
**Created:** [July 31, 2012, 5:00pm UTC](https://forum.kirupa.com/t/javascript-code-help/329198 "2012-07-31T17:00:41Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Vanss472](https://avatars.discourse-cdn.com/v4/letter/v/c77e96/32.png) [@Vanss472](https://forum.kirupa.com/u/Vanss472)
#### Post date: [July 31, 2012, 5:00pm UTC](https://forum.kirupa.com/t/javascript-code-help/329198/1 "2012-07-31T17:00:41Z")

</div>

Hi

I need some help figuring out the remove function from my list.  
It is not working properly any help would appreciated.  
Here the code:

```auto
function List() { this.head = {data:null, next:null};
};

List.prototype.add = function(data) {
     var node = {
         data: data,
         next: this.head
     };
     this.head = node;
};

List.prototype.remove = function() {

      this.head = this.head.next;
      this.head.next = this.head.data;
       
      return this.head.data;  
  
};

```
