# Basic Algorithm Scripting: Homework (fall 2022)

**URL:** <https://group.classcentral.com/t/basic-algorithm-scripting-homework-fall-2022/35896>\
**Category:** JavaScript Bootcamp\
**Created:** [October 3, 2022, 11:38am UTC](https://group.classcentral.com/t/basic-algorithm-scripting-homework-fall-2022/35896 "2022-10-03T11:38:12Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![hola\_soy\_milk](https://sea2.discourse-cdn.com/flex016/user_avatar/group.classcentral.com/hola_soy_milk/32/600_2.png) [@hola\_soy\_milk](https://group.classcentral.com/u/hola_soy_milk)\
**Post date:** [October 3, 2022, 11:38am UTC](https://group.classcentral.com/t/basic-algorithm-scripting-homework-fall-2022/35896/1 "2022-10-03T11:38:12Z")

</div>

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!  
Tomorrow we’ll actually start with Object Oriented Programming. So, please try to complete the section about Basic Algorithm Scripting:

> **[freeCodeCamp.org](https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures)**
>
> Learn to Code — For Free

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🤚

---

<div class="post-metadata">

**Author:** ![stevenr2945563](https://avatars.discourse-cdn.com/v4/letter/s/bc79bd/32.png) [@stevenr2945563](https://group.classcentral.com/u/stevenr2945563)\
**Post date:** [October 17, 2022, 6:30pm UTC](https://group.classcentral.com/t/basic-algorithm-scripting-homework-fall-2022/35896/2 "2022-10-17T18:30:35Z")

</div>

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:

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

```

---

<div class="post-metadata">

**Author:** ![carlost2672543](https://sea2.discourse-cdn.com/flex016/user_avatar/group.classcentral.com/carlost2672543/32/4162_2.png) [@carlost2672543](https://group.classcentral.com/u/carlost2672543)\
**Post date:** [October 17, 2022, 7:45pm UTC](https://group.classcentral.com/t/basic-algorithm-scripting-homework-fall-2022/35896/3 "2022-10-17T19:45:51Z")

</div>

Hi @stevenr2945563

Clever solution! Well done, thank you for sharing.

Happy coding!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex016/uploads/ccstudygroup/original/1X/36206832181ed26910a18e33d8bfef087cf661b1.svg) [@system](https://group.classcentral.com/u/system)\
**Post date:** [December 1, 2022, 7:46pm UTC](https://group.classcentral.com/t/basic-algorithm-scripting-homework-fall-2022/35896/4 "2022-12-01T19:46:38Z")

</div>

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