Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions itsy-bitsy-data-structures.js
Original file line number Diff line number Diff line change
Expand Up @@ -1050,6 +1050,11 @@ class LinkedList {
*/

add(value, position) {
// Throw an error if position is greater than the length of the LinkedList
if (position > this.length) {
throw new Error("Add 'position' parameter should be " + this.length);
}

// First create a node to hold our value.
let node = {
value,
Expand Down