Learn Basic Algorithmic Thinking by Building a Number Sorter - Step 22

Tell us what’s happening:

I am struggling to find the issue with this code. Anyone have any ideas

Your code so far

<!-- file: index.html -->

/* file: styles.css */

/* file: script.js */
// User Editable Region

       if (array[j] > array[j + 1]) {
        let temp = array[j];
        array[j] = array[j + 1];
        array[j + 1] = temp;
      }

// User Editable Region

Your browser information:

User Agent is: Mozilla/5.0 (X11; Linux x86_64; rv:121.0) Gecko/20100101 Firefox/121.0

Challenge Information:

Learn Basic Algorithmic Thinking by Building a Number Sorter - Step 22

They just wanted a const variable.

Thank you! I must have missed that somewhere.

They don’t explicitly say it but you can assume they always want const unless they explicitly say otherwise.

I have had the same problem, i think the word “variable” is equal to “let” and the word “constant” is equal to “const”. They should fix that.

1 Like

In all cases in the fCC curriculum, use const unless explicitly requested not to.

1 Like

also they have asked to change the value of those variables. for the first iteration of j when j=0 (5) arr = [8, 2, 4, 1, 3] 8,2 you need to compare the values of arr[j] and arr[j+1] and if the value of 8 is greater than 2 then the value should change from 8 to 2 and that is the reason why we are creating a temp variable so the value 8 does not get lost.