javascript join address to string
var address = "foo"; var city; var state = "bar"; var zip; text = [address, city, state, zip].filter(Boolean).join(", "); console.log(text)
Here is what the above code is Doing:
1. We create a variable called text and set it equal to an array of strings.
2. We use the filter() method to remove any falsy values from the array.
3. We use the join() method to join the array elements into a string.
4. We log the result to the console.