How to solve Intermediate Algos?

Tell us what’s happening:
I figured out the solution for the challenge ‘Missing Letters’ in the intermediate algos.

However, while i was looking through the FCC solutions, it used CharCodeAt or fromCharCode. So, when i’m trying to solve these intermediate algorithms, should I be using the code that FCC uses? or should I just figure it all out myself with code I already know and understand?

Your code so far


function fearNotLetter(str) {
let allLetters = 'abcdefghijklmnopqrstuvwxyz';
for(let i = allLetters.indexOf(str[0]); i < allLetters.length; i++) {
  if(str.indexOf(allLetters[i])== -1) {
    return allLetters[i]
  }   
}
}

console.log(fearNotLetter("abcdefghjklmno"));

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.88 Safari/537.36.

Challenge: Missing letters

Link to the challenge:
https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/missing-letters

I would suggest you try to solve the challenges first using what you already know. That way you at least go through the problem solving part of the learning process.

After that you can find alternative ways to solve the problem, which is always a good idea. Solving the same problem using different techniques can really help the learning process. This includes looking at the solutions on the hint pages. Just as long as you take the time to understand and learn from them.

It is pretty unlikely that you will know about all the different build-in methods, especially when just starting out. I’d suggest having MDN handy and looking at the different methods for the different types, like Array, String, and Object (the right-hand side of the pages has all the build-in prototype methods).

1 Like

I think that the main reason for doing algorithm practice is to become more and more resourceful.
This pretty much boils down to “solve problems your own way”.

Therefore I usually avoid googling “broad” question like
how to compare and filter two object in javascript

because that will, in my opinion, defile the whole purpose of the challenge.

In all honesty, you can find method to do (for example the above) pretty much anything already made in libraries (Lodash) or in online resources (30SecondsOfCode, Github collections…).

That is why I would suggest you to limit your researches to only methods that comes in your mind just to refresh the syntax (like googling “MDN Array.splice” ).
Then, once you have completed the challenges you can look online and see how other people have solved it, and maybe learn new ways to do it.

This is also what developer will look forward when doing interviews.
Any interviewer knows that for the given challenge there is probably a couple of already-made functions that will help you solve that, but in general they want to see you approach the problem, and not seeing you copy/pasting snippets to achieve the result.

And don’t worry if your solutions don’t seems clever, I have the exact same feelings every time I do one challenge, and I have 4 years of professional experience as a developer.

So do them your way, with limited resources. Then look up online and learn from others.

2 Likes