# Basic Algorithm Scripting: Homework (fall 2022)

Hey JavaScripters!

Great work today! Now we are almost done with Basic Algorithm Scripting and can soon go on to do Object Oriented Programming. How exciting!

Quick reminder about “homework” for the next session!

Remember to take it easy once in a while as well though!
Don’t hesitate to seek help in the js-help channel or on the forum! We are all in this together!

Happy Coding!
#PatPat🤚

During the Telephone Number Validator video, there was a question about “Where Do I Belong?” from Basic Algorithm Scripting. A simpler approach to this problem is to note that you don’t actually need to sort the given array. All you need to do is count how many numbers of the given array are lower than the given number, and that gives you exactly the index of where the number would go after sorting:

function getIndexToIns(arr, num) {
let index = 0;
for (let i of arr) {
if (num > i) {
index++;
}
}
return index;
}
2 Likes

Clever solution! Well done, thank you for sharing.

Happy coding!

2 Likes

This topic was automatically closed 45 days after the last reply. New replies are no longer allowed.