Step 37 For this algorithm, you'll want to use a while loop. This loop needs two conditions:

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

I need help please. I am really stuck here. I keep getting this error message
Sorry, your code does not pass. Hang in there.

Your while loop should decrement j inside the loop.

Hi, can you post a link to the step so we can read it?


Your code looks mostly correct, but it might be a bit too much. This step only requires decrementing the j variable, so there is no need to change the element index yet. Also make sure the curly brackets are closed properly. If you are unsure about the structure of the insertionSort function, you can reset the step and rewrite what is needed.

Additionally, if you share the correct title and related lesson link, it will be easier to find others in a similar situation.

A more accurate title would be “Learn Basic Algorithmic Thinking by Building a Number Sorter - Step 37”. Here is the link to that step:

Happy coding!

@0x74h51N , I do really appreciate. Following your advice I resolved it eventually

1 Like