Skip to content

Commit 934b681

Browse files
committedDec 28, 2016
linked list add
1 parent e2abb00 commit 934b681

10 files changed

+27
-0
lines changed
 
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

‎urlify.js renamed to ‎ch1/urlify.js

File renamed without changes.
File renamed without changes.

‎ch2/linked-list.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
class Node {
2+
constructor(data) {
3+
this.data = data;
4+
}
5+
6+
add(data){
7+
let end = new Node(data);
8+
9+
// iterate
10+
let n = this;
11+
while(n.next) {
12+
n = n.next;
13+
}
14+
15+
n.next = end;
16+
}
17+
18+
19+
}
20+
21+
// usage:
22+
23+
let node = new Node('1');
24+
node.add('2');
25+
node.add('3');
26+
27+
console.log(node);

0 commit comments

Comments
 (0)
Please sign in to comment.