# Learn Basic Algorithmic Thinking by Building a Number Sorter - Step 36

### Tell us what’s happening:

hello everyone.
unfortunately i’m stuck in step 36.

# Step 36

After your while loop, you need to insert your current value. Remember that your loop ends when `j` is either out of the array bounds, or when the value at `j` is less than your current value.

Use the assignment operator to insert your current value into the correct index.

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 + 1] = array[j];
j--;
}
currValue = array[j + 1];
``````

}
}

What do I miss? I simply don’t understand and i’m starting to think that the answer is obvious.

thanks
Marta

WARNING

The challenge seed code and/or your solution exceeded the maximum length we can port over from the challenge.

You will need to take an additional step here so the code you wrote presents in an easy to read format.

Please copy/paste all the editor code showing in the challenge from where you just linked.

``````Replace these two sentences with your copied code.
Please leave the ``` line above and the ``` line below,
because they allow your code to properly format in the post.
``````

User Agent is: `Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36`

### Challenge Information:

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

Welcome to the forum @Uattina18

From the error message, it looks like you should assign the variable to the index.

Happy coding

2 Likes

array[j+1] = currValue;

you were almost there

1 Like

just invert what he did, in case