 # In the normal way what I do ? WARNING (SOLUTION)!

Hi, campers. I am about to finish solving the basic algorithm scripts. But I wonder something. Sometimes, actually most of the time, I have been complicating the algorithms myself. For example, for the “Where do I belong” algorithm, my solutiıon like this and this solution work without problem: After my solution, I looked at the other solutions to see other’s way. But they are so simple. For example like these :

``````function getIndexToIns(arr, num) {

var times = arr.length;
var count = 0;
for (i=0;i<times;i++){
if(num>arr[i]){count++;} }
return count;
}
``````

or

``````function getIndexToIns(arr, num) {

arr.sort(function(a, b) {
return a - b;
});

var i = 0;
while (num > arr[i]) {
i++;
}

return i;
}
``````

Do I want to ask something that am I wrong? Is my solution too long or complicated? Is this normal? Could you give me any advice about my code and my way? By the way, sorry about my English Thank you so much for your obvious answer and advice 1 Like