Tell us what’s happening:
Describe your issue in detail here.
im not able to get this to compile i followed all the suggestions of the hint. what am i doing wrong here
**Your code so far**
function bouncer(arr) {
for (let i = 0; i<arr.length; i++){
Boolean(arr[i]);
console.log(arr[i])
}
arr.filter(arr=>true);
return arr
}
bouncer([7, "ate", "", false, 9]);
**Your browser information:**
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.164 Safari/537.36
the first one changes each elemment to boolean (true or false) . which the hint suggested doing . and the second code filters out and removes the false elements.
The first part doesn’t change anything. And you should not change the elements to true or false anyways. You need to keep the original values of each element.
The second part doesn’t filter anything. The filter() method for an array takes a function as it’s argument, and that function should return true for elements you want to keep and false for elements you want to reject.
And the filter() method does not change the original array, it makes a new array.
Right, but remember that this isn’t a “true accepter” but a “falsy bouncer”. Yes, you’re approach of accepting the opposite of falsy is a good idea, the problem is that the opposite of falsy isn’t “true”, it’s “truthy”. Do you understand the difference? How do you test for truthy?
i came across an example in mozilla and supposedly if u remove the equal sign and everything on the right of it , the if statement test for truthy. and i tried that on my code followed by a console.log statement to verify and i get the right result.