I am working on a JavaScript that uses variables defined by another program. I sat it up to use periods for barometric pressure and GPS coordinates. Some countries use commas instead of periods. Is there an easy way to have the JavaScript change a variable if it has a comma instead of a period to a period but also to not mess it up if it already has a period?

For example:

var l = 39.4259
var r = 30.06

Now if the program is sat to use commas (changing those to 39,4259 and 30,06) how can I change those commas to periods only when commas are used?