diff --git a/src/data-structures/linked-list/LinkedList.js b/src/data-structures/linked-list/LinkedList.js index 587177f9b4..dd55d51663 100644 --- a/src/data-structures/linked-list/LinkedList.js +++ b/src/data-structures/linked-list/LinkedList.js @@ -190,10 +190,17 @@ export default class LinkedList { return nodes; } + /** + * @param {LinkedListNode[]} array - Array of nodes + */ + fromArray(arr = []) { + arr.forEach(node => this.append(node.value)); + } /** * @param {function} [callback] * @return {string} */ + toString(callback) { return this.toArray().map(node => node.toString(callback)).toString(); }