you have a truthy statement of “value”, and it should be a falsey statement of !value.
const falsei = ["", 0, false, null, undefined];
console.log(countTruthy(falsei));
function countTruthy(falsei) {
let count = 0;
for (let value of falsei) {
if (!value) count++;
}
return count;
}
const falsei = ["", 0, false, null, undefined]; //creating a variable.
console.log(countTruthy(falsei)); // console.log is writing to the console. (countTruthy(falsei) is executing the function (to the console).
function countTruthy(falsei) { // calling the parameter, located outside of the function.
let count = 0;
for (let value of falsei) { //since the variable was called, it can be used inside the function.
if (!value) count++;
}
return count;
}
You may need to find outside resources to explain ‘things’ better. Such as argument/parameter. Which Mosh did explain in one of his videos. Also, truthy/falsey. And many other things. You will not be able to watch the video once and ‘take it all in’. Review… review… review! Redo the quizzes… redo the quizzes… redo the quizzes. Understand what the program is trying to do.