Finally completed the Basic Algorithm Scripting section

Took me 3 days to complete it all. It was tough/tiring and I’m glad that its over. It was interesting though.
Here is my code of the last two challenges Mutations and Chunky Monkey. Would love any feedback.

**Mutations** 
 function mutation(arr) {
    let count=0;
    for(let i=0;i<arr[1].length;i++){
      if(arr[0].toLowerCase().indexOf(arr[1][i].toLowerCase())!=-1){
        count+=1;
      }    
    }
    console.log(count);
    
    if(count==arr[1].length){return true};
    {return false;}
}

console.log(mutation(["Mary", "Army"]));
**Chunky Monkey**

Even though I did it myself, I initially didn’t understand how it worked like why +size instead of +1 but figured it out using pen and paper and added comments for it.


function chunkArrayInGroups(arr, size) {
let a=[];
let b=arr.slice();
for(let i=0;i<b.length;i+=size) 

/*+size used to indicate say size=2, then 2 elements from arr 
has been used up, more two has been used up, now we only 
have empty left*/
    {
      a.push(arr.splice(0,size));
    }
console.log(a);
return a;
}

chunkArrayInGroups([0, 1, 2, 3, 4, 5], 2);

Final Words after seeing the solutions and a question

I saw the solutions after I solved the challenge, one problem had like 5 solutions. Even though I did study all the solutions for the very last challenge, it was really painful like going through each and everyone of them. I have skipped doing that in some of the solutions of some of the previous challenges as they looked pretty hard/difficult to understand without deliberate effort. Hope its okay as long as I figured out one correct way to do it.

I wonder what’s the difficulty level of the next 3 remaining sections and also of the next certifications and all? :upside_down_face:

Congratulations!

Once you start working on more and more difficult coding tasks/projects, these algo challenges will seem easier and easier to you :smiley:

1 Like

Nice work making it this far!

The intermediate algorithm challenges can be hard for a lot of people, but I think they are really good practice for describing and solving problems. The functional and OO sections give you a lot more syntax and tools to be able to solve problems with, which makes your life easier once you get used to these tools.

1 Like

That’s absolutely ok. You’ll automatically pick up more advanced concepts, syntax and methods while you progress.

I’ve added a few comments to your mutation solution, and changed some (minor) things:


function mutation(arr) {

   // use array destructuring to extract the two strings
   // and convert them to lowercase right away
   // (just makes the following code more readable)

   let [str1, str2] = arr;
   [str1, str2] = [str1.toLowerCase(), str2.toLowerCase()];

   let count = 0;

   for (let i=0; i<str2.length; i++){
      if (str1.indexOf(str2[i]) !== -1){ // use strict equality !== instead of !=
        count++;
      }    
   }

   if (count === str2.length){return true}; // same about the equality operator

   return false; // you don't need curly braces around this statement
}


As for your chunkyMonkey solution, I really don’t have anything to criticise, the only thing I’d mention is that using .slice to create a new array is sort of the “old fashioned” way. Nowadays, you’d use the spread operator:

let b = [...arr];

What this line is doing:

  • create a new empty array (as indicated by the square brackets)
  • spread all the items of arr into that empty array

It’s just a very common syntax and you might come across it often. I’m not sure at which point the fCC curriculum teaches it (or if it has been taught already).

Good luck with proceeding to the next sections, seems you’re on a good way.

2 Likes

These were hard but not that kind of hard that you want to give up. That kind of hard where you keep working on it till late night to have it solves because you know you can do it. Had fun solving it even though it took some time. :blush:

What about the other certifications? How difficult/hard are they as compared to this certification? Like for example Front End Libraries, D3 and others?

Thank you so much for your feedback and the code. :heart: :heart: :heart:

… has been taught already and I have used it in some of the previous challenges, I would have used it and if I had thought about it a bit more but I saw the slice being used to copy in some of the previous solutions so I used it.

I realize these days how code could be a sort of “art” lol idea expressed beautifully :upside_down_face:

It gets harder and harder. You’re learning more and more real-world stuff, so it is expected to become harder and harder. But you’re gaining experience as you progress along the way, so you know the expectation and won’t get too frustrated. And mastering, or conquering, the harder stuff will be more rewarding and fulfilling.

First, the topics become more advanced and take more time to really understand. Second, the coverage and explanation of topics on FCC are not as broad and kind as the beginners would need. They discuss some topics using just one or two challenges, but in my opinion, that is simply not enough. The gap between what are covered in the lessons and the difficulty and scope of the five projects for certification is quite big. This gap becomes more profound as you progress through the certifications. [This is purely one participant’s casual observation and impression, not a result of any analysis or study, of course. I’m also speaking about the JavaScript track only.]

You need to something to fill the gap. This is the reason why I always suggest people to have two or three different learning sites. Another suggestion I have is to take online classes, if possible, to learn the main subject matters. Most of these online classes (free or paid) teach the subject matter but don’t offer exercises or projects. You use FCC for such purpose. I’m taking several several courses myself from a well known site (I only register when they offer a course for something like $12.99, a 90% discount). Some are awful, so you have to be careful, but several of them are quite good in covering React, Node Express, Mongo, and D3.

Keep on coding and learning.

1 Like

Thank you for your answer.

Yes, one things that I noticed was that the certifications like D3(39 lessons), APIs and Microservices(34 lessons), Quality Assurance(47 lessons) etc were quote short as compared to the other certifications which had like 100+ in one section only. Maybe 200+ lessons in total. Maybe it’s the gap in things taught and things that one needs to know in project that’s making the lessons less in number.

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