this.addAt = function(index, element){
if (index < 0 || index >= length) {
return false;
}
let currentNode= head;
if (index > 0) {
let tracker= 0;
while (tracker+1 !== index) {
currentNode= currentNode.next;
tracker++;
}
}
const newNode = new Node(element);
newNode.next = currentNode.next;
/
index === 0? head = newNode: currentNode.next = newNode
length++;
};
Please provide a link to the Step. Also, please put your question in the post body. Thanks
My logic seems right but I don’t really know why I can’t pass question one where it said if index is 0, reassign head to new node.
thanks
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.