Trouble with Basic Algorithm Scripting - How to handle it?

Hi!

I am taking the Basic Algorithm Scripting course and I have not completed any challenge on my own other than the first. In challenges 2-5 I read the hints and couldn’t do it, so I saw the solutions. I understood some (at least two of each challenge), but not all.

In doing so, I learned a little, but it hasn’t helped me improve my approach to the next problem (how to use the codes to get things done).

I started JS courses last Tuesday, so the codes are not really fixed in my head. And I don’t know much about some (.map (), for example).

So, I would like to ask which step should I take:
(1) I keep doing this and, at some point, I will understand?
(2) stop doing that and look out all the codes, understand them better, and find out how to use them for each problem?
(3) other?

Thanks!! =D

The fist thing that you need to know is that this is hard. You’re now at a point where you’re not just expected to follow instructions for syntax. You need to take the time to creatively solve problems. While there are some things that you can learn by looking at hints and solutions, it won’t really make you better at solving this type of problem. I strongly urge you not to rely on looking at the solutions. It’s perfectly fine for these challenges to take a long time, to require research, or for you to ask for help.

4 Likes

Hi @MarcosSouza !

It has been a week of learning javascript so you are not expected to remember everything. It takes time to get comfortable when you are learning something new. Patience is key. With practice and time things will start to make more sense.

I vote for other.

Algorithms help you learn how to problem solve.
Start with pen and paper and work out the problem without code.
Then write out the basic steps to solve the problem(ex. if this happens then I should do this)
Then slowly translate that into code.

It will help to have MDN Docs open for a reference.

For extra practice you can look into these sites.

1 Like

Thanks for the reply @ArielLeslie and @ jwilkins.oboe.

I understood what you two are saying. I will follow your advice. It seems like the best way to go.

Thank you very much!! It’s very good to have this help. :smiley: :smiley: :smiley:

Hi @ArielLeslie @jwilkins.oboe!

I managed to do 4 challenges! = D
The first one was very big, but that’s okay. The second and third looked better. On the 4th I did and was fulfilling the checklist items (when looking at console.log), but it was not marking the item, as if it were wrong. I ended up looking for solutions quickly (sorry), to see if there were any similar ones. The only difference is that I was assigning “” to the variable, while the solution was assigning 0. I changed the “” to 0 and it worked. But I couldn’t understand why it was wrong with “”. If possible, could you explain the reason for this?

// Finders Keepers
function findElement(arr, func) {
  let num = 0; // That was the variable that I was assigning "" (let num = "";).
  for (let i = 0; i < arr.length; i++) {
    if (func(arr[i]) === true) {
      console.log(num + arr[i]);
      return num + arr[i];
    }
  }
  return undefined;
}

findElement([1, 3, 5, 8, 9, 10], function(num) { return num % 2 === 0; });

Thanks!!

It would make more sense to have 0 + arr[i] instead of “” +arr[i]
Remember that you want to return a number if it passes the truth test.

You can see your code a little bit clearer in the console.

Your version returns a string

Whereas the correct version returns a number

Hope that makes sense!

1 Like

Hey @jwilkins.oboe!
It makes sense. The strange thing is that on my console it appeared the 8 without quotes.


But makes sense.
Thanks for everything!! =D

Yeah, that’s why I showed you with the chrome developer tools.
I am not sure why the quotes don’t show up for strings in the fcc console :thinking:

1 Like