Assessment wanted for JSON skill test (Task 1)

Can I have some feedback about my take on this task?

Link to the task: https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Objects/Test_your_skills:_JSON

Here is my take: https://jsfiddle.net/5rpq9b87/

Thank you.

Hi @Drow and welcome to the community :wave:

Great work on this exercise :+1:

Everything works as expected and I have only some remarks which could make the code simpler or less error-prone:

  • Overwritting the catString function parameter may be confusing. Especially because the new value is an array. This may be cleaner: const cats = JSON.parse(catString);
  • Since you’re not using the loop indexes (other than selecting the value of the array), you could convert them to for...of loops to improve readability.
  • Instead of concat() you could just use motherInfo = motherInfo + ... like you did above. (or even motherInfo += ...)

Once again, nothing wrong with you code just some alternatives to think about :slightly_smiling_face:

Do you have an answer to the additional question?

Why are the para1.textContent = motherInfo; and para2.textContent = kittenInfo; lines inside the displayCatInfo() function, and not at the end of the script? This has something to do with async code.

Keep up the great work,
Michael

Thank you for the feedback Mr. Koch.

1 Like