Skip to content

Commit

Permalink
refactor(insertion-sort): ♻️ no need to check on j <= 0
Browse files Browse the repository at this point in the history
any trythy >= undefined anyway
  • Loading branch information
AndrewLawendy authored Jul 23, 2022
1 parent 5b2edb0 commit 6aa7668
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion specs/insertion-sort/insertion-sort.solution.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function insertionSort(nums) {
let j; // the inner counter

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

0 comments on commit 6aa7668

Please sign in to comment.