I’m getting through the Basic Algorithm Scripting challenges at a reasonable pace, but I’m worried that I’m not getting as much as I could out of them as my answers vary significantly from those found on GitHub.

For example, see my answer to “Where Do I Belong” vs the one shown here:

mine:

```
function getIndexToIns(arr, num) {
function compareNumbers(a, b) {
return a - b;
}
var sorted = arr.sort();
for(var i=0; i <sorted.length; i++) {
if (num > Math.max(...sorted)) {
return sorted.length;
} else if (num <= Math.min(...arr)) {
return 0;
} else if(num === sorted[i]){
return sorted.indexOf(sorted[i]);
}else if (num >= sorted[i] && num <= sorted[i+1]) {
return sorted.indexOf(sorted[i])+1;
}
}
}
getIndexToIns([2, 5, 10], 15);
```

Suggested:

```
function getIndexToIns(arr, num) {
arr.sort(function(a, b) {
return a - b;
});
for (var a = 0; a < arr.length; a++) {
if (arr[a] >= num)
return parseInt(a);
}
return arr.length;
}
```

Clearly the second version is much more efficient and mine is the product of a lot of guess work - is this something I should be concerned about? How can I improve my solutions?