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!

:loudspeaker: Quick reminder about “homework” for the next session!
Tomorrow we’ll actually start with Object Oriented Programming. So, please try to complete the section about Basic Algorithm Scripting:

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!

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) {
  return index;

Hi @stevenr2945563

Clever solution! Well done, thank you for sharing.

Happy coding!


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