Assessment wanted for JSON skill test-1

Hi, I would like my work assessed.

link to the assessment: https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Objects/Test_your_skills:_JSON#json_1

link to my Codepen: https://codepen.io/ashwinsoni86/pen/wvyWNxL

thanks in advance!!

Hi @ashwinsoni86 and sorry for the long waiting time :sweat_smile:

Nice work on this exercise! :clap:

Here are some comments:

  • Try to use consistent indention for better readability. Check out the differences when you hit “Format JavaScript” in CodePen.
    2022-05-15 17_36_15-JSON
  • I would prefer “dot notation” over “bracket notation” where possible:
    /* harder to read */
    catObj[i]["name"]
    /* easier to read */
    catObj[i].name
    
  • Since we don’t need the index inside the inner loop, we could make it easier by using for..of:
    for (const kitten of catObj[i].kittens) { ... }
    
  • You used total++; in if and else. You could just put it outside the if...else condition once.

Feel free to ask questions if something is unclear. :slightly_smiling_face:

Happy coding,
Michael

1 Like

Thanks @mikoMK for the feedback. I will definitely work on them.

1 Like