We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent f3fe049 commit 1fa875fCopy full SHA for 1fa875f
src/data-structures/linked-lists/linked-list.js
@@ -7,10 +7,12 @@ const Node = require('./node');
7
* the last and first element
8
*/
9
class LinkedList {
10
- constructor() {
+ constructor(iterable = []) {
11
this.first = null; // head/root element
12
this.last = null; // last element of the list
13
this.size = 0; // total number of elements in the list
14
+
15
+ Array.from(iterable, (i) => this.addLast(i));
16
}
17
// end::constructor[]
18
0 commit comments