I’ve always wanted to study programming. 10-12 years ago I learned how to make websites on Wordpress, using Adobe Muse and layout simple lendings on html. I studied internet marketing, setting up contextual and teaser advertising. Then it was a long break because of health problems. For several years I was unable to work or study. Now I am recovering and can learn again. I started studying at Rsschool because I want to become a full-stack developer.
Consider an array/list of sheep where some sheep may be missing from their place. We need a function that counts the number of sheep present in the array (true means present).
function countSheeps(sheep) {
if (!sheep || !Array.isArray(sheep)) {
return 0;
}
let newSheep = sheep.filter(val => val === true);
return newSheep.length;
}