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.
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
Great work on this exercise
Everything works as expected and I have only some remarks which could make the code simpler or less error-prone:
catString
function parameter may be confusing. Especially because the new value is an array. This may be cleaner: const cats = JSON.parse(catString);
for...of
loops to improve readability.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
Do you have an answer to the additional question?
Why are the
para1.textContent = motherInfo;
andpara2.textContent = kittenInfo;
lines inside thedisplayCatInfo()
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.