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

Tell us what’s happening:

not quite sure if Im doing this right just looking for some guidance

Your code so far

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

/* file: styles.css */

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

const insertionSort = (array) => {
  for (let i = 1; i < array.length; i++) {
    const currValue = array[i];
    let j = i - 1;

    while (j >= 0 && array[j] > currValue) {

      array[j] = array[j + 1];
        j--;
    }
  }
}

// User Editable Region

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.5 Safari/605.1.15

Challenge Information:

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

Hi @4hvcv6nxzn

Before decrementing j , assign the value at j to the index j + 1 .

I way I read it, you need to access the j+1, then assign it the j value.

Happy coding