Day 44: 15 September 2020
I started the Intermediate Algorithm Scripting Challenges on freeCodeCamp !
Spent the rest of my free time reading articles and fixing this blog.
We create a variable to store the sum of every number in the given range.
Then we sort the array. This method will check every value in our array in sequence and it operates a swap between the values if needed.
Once the array is sorted, we calculate the total using the first number as starting index for our for cycle. The second number will be our loop condition. Particular attention to the = (equal sign) to avoid off-by-one errors.
This caused me a bit of a headache just because I didn't remember studying the includes method at all (or I didn't knew before... I still can't find it in this blog nor my personal bloc-notes).
I found the answer thanks to a mixture of:
- google search about arrays methods
- Set Theory
We exclude from the first set the elements that are not included in the second set.
We exclude from the second set the element that are not included in the first set.
We make the union of these two sets.
I cannot still believe that I am progressing so fast since the beginning of the #100DaysOfCode challenge.
**Link to tweet:**