Assessment/correction wanted for JSON skilled test

function displayCatInfo(catString) {

let total = 0;

let male = 0;

let catObj = JSON.parse(catString);

for (let i = 0; i < catObj.name.length; i++) {

if (i == catObj.length-1) {

    motherInfo += catObj[i].name + '. ';

}  else {

    motherInfo += catObj[i].name + ', ';

}

total += catObj[i].kittens.length;

for (let j = 0; j < catObj[i].kitten.length; j++) { 

    if(catObj[i].kittens[j].gender == "m")  {

        male += 1;

    }  else  {

        continue;

    }  

}

}

kittenInfo = ‘male kittens: ’ + male + ‘;’ + ’ total kittens: ’ + ’ total’ + ’ ;’

  • ’ female kittens: ’ + total - male + ‘.’

That code is really hard to read and assess.
Can I suggest you edit your post to put it in a code block?

In the interface, that’s the button that looks like </>. It will make the code much easier to assess :slight_smile:

I think this link should do better. https://codepen.io/Benarivo/pen/WNrLeVp

Thanks