We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 54da31a commit 0852027Copy full SHA for 0852027
chapter05/01-Linked-List.js
@@ -149,15 +149,15 @@ function LinkedList() {
149
150
this.toString = function(){
151
152
- var current = head,
153
- s = current.element;
+ var current = head,
+ string = '';
154
155
- while(current.next){
+ while (current) {
156
+ string = current.element;
157
current = current.next;
- s += ', ' + current.element;
158
}
159
+ return string;
160
- return s.toString();
161
};
162
163
this.print = function(){
0 commit comments