DEV Community

Discussion on: Let's Count Some Sheep!

Collapse
deepslog profile image
deepslog

Checkout:
var sheep1 = [
true, true, true, false,
true, true, true, true,
true, false, true, false,
true, false, false, true,
true, true, true, true,
false, false, true, true
];
function countSheep(sheep1) {
count = 0;
for (let value of sheep1)
if (value)
count++;
return count;
}
console.log(countSheep(sheep1));