You can remove all “falsy” values from an Array by filtering for Boolean
.
const friends = ['Jake',null,'Cassidy',undefined,'Joshy',undefined,'Jordyn']const filteredFriends = friends.filter(Boolean)
filteredFriends // ["Jake", "Cassidy", "Joshy", "Jordyn"]