js-mentorship-razvan / javascript

Javascript study notes
GNU General Public License v3.0
22 stars 2 forks source link

Solve 'Counting sheep...' #319

Closed odv closed 5 years ago

odv commented 5 years ago

https://www.codewars.com/kata/counting-sheep-dot-dot-dot/train/javascript

RazvanBugoi commented 5 years ago

@odv I think the tests are broken. It says to check for bad values but doesn't specify what to return in that scenario.

function countSheeps(arrayOfSheep) {
  let numberOfSheeps = arrayOfSheep.filter( (sheep) =>  sheep == true );
  return numberOfSheeps.length > 0 ? `There are ${numberOfSheeps.length} sheeps in total` : `There are no sheeps at all`;
}
RazvanBugoi commented 5 years ago
function countSheeps(arrayOfSheep) {
  return arrayOfSheep.filter( (sheep) =>  sheep == true ).length;
}