```
function getIndexToIns(arr, num) {
let myArr = [...arr];
myArr.sort((a, b) => a-b);
for (let i = 0; i < myArr.length; i++) {
if (num === myArr[i]) { return i;}
else if (num > myArr[i] && num < myArr[i+1]) {
return i+1;
}
}
if (arr.length === 0) {
return 0;
} else {
return arr.length;
}
}
```

How is the code, and can you propose some improvements? And thank you in advance!

Link to the challenge ( Basic Algorithm Scripting: Where do I Belong) : https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/basic-algorithm-scripting/where-do-i-belong