mirror of
https://github.moeyy.xyz/https://github.com/trekhleb/javascript-algorithms.git
synced 2024-12-28 07:59:42 +08:00
Fix lint issue.
This commit is contained in:
parent
2a49b7045a
commit
9ca459ff65
@ -56,11 +56,11 @@ export default class LinkedList {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {*} value
|
* @param {*} value
|
||||||
* @param {*} index
|
* @param {number} index
|
||||||
* @return {LinkedList}
|
* @return {LinkedList}
|
||||||
*/
|
*/
|
||||||
insert(value, index) {
|
insert(value, rawIndex) {
|
||||||
index = index < 0 ? 0 : index;
|
const index = rawIndex < 0 ? 0 : rawIndex;
|
||||||
if (index === 0) {
|
if (index === 0) {
|
||||||
this.prepend(value);
|
this.prepend(value);
|
||||||
} else {
|
} else {
|
||||||
@ -70,7 +70,7 @@ export default class LinkedList {
|
|||||||
while (currentNode) {
|
while (currentNode) {
|
||||||
if (count === index) break;
|
if (count === index) break;
|
||||||
currentNode = currentNode.next;
|
currentNode = currentNode.next;
|
||||||
count++;
|
count += 1;
|
||||||
}
|
}
|
||||||
if (currentNode) {
|
if (currentNode) {
|
||||||
newNode.next = currentNode.next;
|
newNode.next = currentNode.next;
|
||||||
|
@ -45,7 +45,7 @@ describe('LinkedList', () => {
|
|||||||
linkedList.insert(10, 9);
|
linkedList.insert(10, 9);
|
||||||
|
|
||||||
expect(linkedList.toString()).toBe('1,4,2,3,10');
|
expect(linkedList.toString()).toBe('1,4,2,3,10');
|
||||||
})
|
});
|
||||||
|
|
||||||
it('should delete node by value from linked list', () => {
|
it('should delete node by value from linked list', () => {
|
||||||
const linkedList = new LinkedList();
|
const linkedList = new LinkedList();
|
||||||
|
Loading…
Reference in New Issue
Block a user