Skip to content

Commit 734c951

Browse files
added ts and solved 8kyu
1 parent fb27ba6 commit 734c951

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
"use strict";
2+
// outputs a number counting the trues in the array
3+
// input is an array of boolean values, it can have null or undefined
4+
//
5+
Object.defineProperty(exports, "__esModule", { value: true });
6+
exports.countSheeps = void 0;
7+
function countSheeps(arrayOfSheep) {
8+
return arrayOfSheep.filter(Boolean).length;
9+
}
10+
exports.countSheeps = countSheeps;
11+
console.log(countSheeps([true, true, true, false, true, true, true, true, true, false, true, false, true, false, false, true, true, true, true, true, false, false, true, true]), "should result in ".concat(17));
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// outputs a number counting the trues in the array
2+
// input is an array of boolean values, it can have null or undefined
3+
//
4+
5+
export function countSheeps(arrayOfSheep: (boolean | undefined | null)[]): number {
6+
return arrayOfSheep.filter(Boolean).length
7+
}
8+
9+
console.log(
10+
countSheeps([true, true, true, false, true, true, true, true, true, false, true, false, true, false, false, true, true, true, true, true, false, false, true, true]),
11+
`should result in ${17}`
12+
)

0 commit comments

Comments
 (0)