Tell us what’s happening:
I am using reduce function here, But I don’t know why… certain cases fail.
Your code so far
function getIndexToIns(arr, num) {
arr.push(num);
arr.sort().reduce(function (curr,prev){
return curr - prev;
});
return arr.indexOf(num);
}
getIndexToIns([40, 60], 50);
Your browser information:
Your Browser User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.108 Safari/537.36
.
Link to the challenge:
https://www.freecodecamp.org/challenges/where-do-i-belong