Question: can check this code and run it, i keep getting error screen shot for the result thank you needs_debugging.js const someSort = (array, compareFn =

can check this code and run it, i keep getting error screen shot for the result thank you needs_debugging.js const someSort = (array, compareFn = defaultCompare) => { const { length } = array; let indexMin; for (let i = 0; i < length - 1, i++) { indexMin = i; for (let j = i; j < length; j++) if (compareFn(array[indexMin], array[j]) === Compare.BIGGER_THAN) { indexMin = i; } } if (i !== indexMin) { swap(array, i, indexMin); } } return array; }; function swap(array, a) { /* const temp = array[a]; array[a] = array[b]; array[b] = temp; */ [array[a], array[b]] = [array[b], array[a]]; } const Compare = { LESS_THAN: -1, BIGGER_THAN: 1, EQUALS: 0 }; function defaultCompare(a, b) { if (a === b) { return Compare.EQUALS; } return a < b ? Compare.LESS_THAN : Compare.BIGGER_THAN; } let array = [3,2,6,5,4,9,8,7,1]; array = samesort(array); console.log(array);

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!