Assessment wanted for JSON skill test. (Task 1)

Assessment wanted for JSON skill test. (Task 1)

Link to task:

Link to my code:

Thanks :wink:

Hi again, @EiN

Great work! Here are some comments:

  • Regarding your first comment. You did the right thing by using cats.length to decide what to put after the name. The wrong approach would be to use fixed numbers like
    if (i === 2) {
      motherInfo += `${cats[i].name}.`;
  • You could make the “kitten counter” simpler by only counting one gender and calculating the other in the template string (e. g. ${total - male}).
  • Your reasoning in the second comment is wrong. The two variables motherInfo and kittenInfo are declared outside the function (at the beginning of the given code). So assigning the values from inside does indeed work. The actual problem is that fetch() is an asynchronous function. If the assignments were outside displayCatInfo(), they would happen before the results from fetch() arrives and the function is called.

I hope my explanations make sense. :slightly_smiling_face:


1 Like

I am glad that I was able to make the right decision for this task.

About simplifying “kitten counter”. Everything is clear, I just needed to think a little more. :slightly_smiling_face:

Regarding the asynchronous function.
I have read the following articles:
To be honest, the understanding of these things has not yet fully come. I think that in the future, when I use asynchronous functions, with experience of use, a greater understanding will come, while everything is very superficial. I hope that further, in the next lessons, this topic will be revealed a little deeper and with practical tasks.

1 Like

Yeah, asynchronous JavaScript is a bit hard to understand at the beginning, but I think the lessons about this topic are well made. It certainly is a very interesting topic (at least to me :slight_smile:). I’m pretty sure you’ll eventually understand it.

1 Like