const userInput = "2a smith road";
const secondInput = "333 flathead lake road, apartment 3b"
const formattedAddress = userInput.replace(/(^\w{1})|(\s+\w{1})/g, letter => letter.toUpperCase());
The final result will be:
userInput = "2A Smith Road"
secondInput = "333 Flathead Lake Road, Apartment 3B"