I have a function that is supposed to loop through an array and count the values in the array that are true. in the example below, I am expecting a value of 4, since the values 6, 3, 30, and 7 are all truthy values while 0 is false.
function countTruthy(arr) {
var arrayLength = arr.length;
var truthy = 0;
for (var i = 0; i < arrayLength; i++) {
if(arr[i] == true) {
truthy++
}
}
return console.log(truthy)
}
countTruthy([6, 3, 0, 30, 7])
But the code above doesn't work and I keep getting 0 instead