Day 19: Cool Feature of Filter Method

I'm feeling a bit better today. Wow this coding journey really does have some ups and downs. I spent the majority of the day working on the wedding website. I added an "Our Love Story" Timeline and it actually looks pretty good! I played around with pseudo elements to get the timeline border and points. I still have a few more sections to add and I"m behind on this project, but that's because I've been devoting so much time to reviewing JavaScript.

While working on my questions for Bridge School, I came across this neat pice of code. Say you have an array, and you want to remove all falsey items and return a new array:

myCoolArray = [3, 2, "", false, NaN, 5, 0, null, undefined]

filteredArray = myCoolArray.filter(Boolean)

console.log(filteredArray); // [3, 2, 5]

Volia! Magic! I believe this works because Boolean acts as a function that coerces each value in the array to a boolean. It returns true for truthy values and false for falsey values. The filter function then returns all values that are true.