Hướng dẫn thử thách
1 / 1
Implement Linked List Operations
In this lab, you will implement additional operations for a linked list data structure, building on the basic functionality of adding and removing nodes.
**Objective**: Fulfill the user stories below and get all the tests to pass to complete the lab.
**User Stories:**
1. You should have a `contains` function that accepts a linked list and an element. It should return `true` if the specified element exists in the linked list, and `false` otherwise.
1. You should have a `getAt` function that accepts a linked list and an index. It should return the element at the given index in the linked list. If the index is out of bounds, it should return `undefined`.
1. You should have a `insertAt` function that accepts a linked list, an index, and an element. It should insert the given element at the specified position in the linked list. If the index is out of bounds, it should not modify the list.
1. You should have a `removeAt` function that accepts a linked list and an index. It should remove the node at the given index in the linked list. If the index is out of bounds, it should not modify the list.
1. You should have a `clear` function that accepts a linked list. It should remove all elements from the linked list, effectively resetting it to an empty state.
**Note:** Some later tests rely on earlier methods. For example, if `getAt` is not implemented correctly, tests for functions like `insertAt` and `removeAt` may fail even when those functions are close to correct.
Vượt qua bài kiểm tra hiện tại để mở khóa bài tiếp theo.
main.js
UTF-8 • Tab Size: 2Kiểm tra bài:⌘↵