The condition doesn't have to be a boolean. JavaScript converts any value:
let username = "Alice"
if (username) {
console.log(`Welcome, ${username}`)
}
This works because non-empty strings are truthy. Common patterns include:
if (array.length) { } // Has items?
if (user) { } // User exists?
if (count) { } // Non-zero?
Remember the falsy values: false, 0, "", null, undefined, NaN.