I am currently working through the Han Academy Algorithm Course, which uses JS to teach fundamental algorithms. I am currently sorting an insert, but found a problem.
We write a function that takes an array, an index for the beginning, and values to insert the number into the correct ordered position. I wrote a function here:
var insert = function(array, rightIndex, value) { for (var i = rightIndex; array[i] >= value; i--) { array[i+1]=array[i]; array[i] = value; } return array; };
This works great and works as it should, but it doesn’t go through the automatic KA marking system. They give recommendations for the code and suggest to do it as such:
for(var ____ = _____; ____ >= ____; ____) { array[____+1] = ____; } ____;
Does anyone know how I can repeat my code to fit these standards?
dlb24 source share