Skip to content

Commit e33bda6

Browse files
committed
refactor(insertion-sort): ♻️ no need to check on j <= 0
1 parent 5b2edb0 commit e33bda6

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

specs/insertion-sort/insertion-sort.solution.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ function insertionSort(nums) {
1414
let j; // the inner counter
1515

1616
// loop from the right to the left
17-
for (j = i - 1; nums[j] > numberToInsert && j >= 0; j--) {
17+
for (j = i - 1; nums[j] > numberToInsert; j--) {
1818
// move numbers to the right until we find where to insert
1919
nums[j + 1] = nums[j];
2020
}

0 commit comments

Comments
 (0)