
Pragmatic FullStack Lead Developer and Teacher. #PHP and #JS enthusiast, #OSS regular. Professional account, open to work. ⏩ @mathieutu.dev 🦋
- Tweets2.3K
- Following261
- Followers208
- Likes2.4K

ALT // Avoid: Mutates formattedAddress let formattedAddress = ""; switch (user.country) { case "USA": formattedAddress = // Logic for formatting USA address here case "UK": formattedAddress = // Logic for formatting UK address here default: throw new Error("Unhandled country") } // --------------------------------------------------------------------------------- // Instead, call a function const formattedAddress = formatAddress(user); // Return early to eliminate the need for let. function formatAddress(user) { switch (user.country) { case "USA": return formatUsaAddress(user) case "UK": return formatUkAddress(user) default: throw new Error("Unhandled country") } }


























