Tell us what’s happening:
I tried various solutions and even found two posts in forum to same question and read all the posts, but could not find solution. I also tried AI and he was wrong too. I tried all combinations, like reversing left and right, trying indexes of array or currentValue…
Btw, I found solution here: https://youtu.be/y_ZlQhEAvHs?t=266
But when I write exactly same code it does not work! Maybe you broken it somehow and nobody can now solve it. Can you try solving it in this moment?
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+1] = array[j];
j--;
}
}
}
// User Editable Region
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36
Challenge Information:
Learn Basic Algorithmic Thinking by Building a Number Sorter - Step 38