*I have the function presented below to extract prices from free text. In the process of onboarding a new client, they have items aimed at the French market where prices sometimes have the currency symbol in a different position, for example "19€99". How would you rewrite or change the way this algorithm works to accommodate this new requirement and future such requirements? Why would you do it the way you propose?
here is the code
`var valid_countries = ["US", "IT"]`
function extractPrice(description, country){
if (!valid_countries.includes(country)){
return -1
}
if (country == "US") {
var price = description.match(/\$(\d+\.\d+)/)[1]
if (price == null) {
return -1
}
return parsreFloat(price)
}
if (country == "IT") {
var price = description.match(/\€(\d+\.\d+)/)[1]
if (price == null) {
return -1
}
return parsreFloat(price)
}
}