Ashok Be
Ashok Be
Mar 28 · 1 min read

Equivalent JavaScript code


function selectSortR(a){
if (!a.length) return []; // #1, terminal case

let minVal = Math.min.apply(null, a); // #2
a.splice(a.indexOf(minVal), 1); // #3
return [minVal].concat(selectSortR(a)); // #4 and #5
}
Ashok Be

Written by

Ashok Be

Entrepreneur, struggle-to-code evangelist, paradox collector, green tea and black coffee enthusiast. And yes, squash!