We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 181e14b commit a8e7286Copy full SHA for a8e7286
src/code-challenges/bubble-sort.js
@@ -6,12 +6,11 @@
6
7
// Normal
8
function bubbleSortVariationNormal(arr) {
9
+ const len = arr.length - 1;
10
let swaps;
11
do {
12
swaps = false;
- for (let i = 0; i < arr.length - 1; i++) {
13
- const element = arr[i];
14
- console.log(element);
+ for (let i = 0; i < len; i++) {
15
if (arr[i] > arr[i + 1]) {
16
// start with the first two elements and sort them in ascending order. (Compare the element to check which one is greater).
17
let temp = arr[i + 1]; // store second element for swap
0 commit comments