**Normal syntax, arrow syntax, and …? **
I solved the challenge and I can continue but I always take a look at the different types of solutions just to learn something new. This time I can not figure out why does proposed solution work (I guess it is something really simple). Look at the code below.
**My code that works **
function bouncer(arr) {
let result = [];
for (let i = 0; i < arr.length; i++) {
if (!!arr[i]) {
result.push(arr[i]);
}
}
console.log(result);
return result
}
bouncer([7, "ate", "", false, 9]);
**Proposed solution**
function bouncer(arr) {
let newArray = [];
for (let i = 0; i < arr.length; i++) {
if (arr[i]) newArray.push(arr[i]);
}
return newArray;
}
bouncer([7, "ate", "", false, 9]);
First of all, I do not get why there are not any curly brackets around if statement when there is not used syntax with an arrow. Secondly, I do not get where they check if the value is boolean or not. I have read on the internet that for this check I can use either “!!something” or " Boolean(something)". Because of those two points, I am a bit confused.
**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.114 Safari/537.36
Challenge: Falsy Bouncer
Link to the challenge: