Help, how can I replace commas with periods?

Hi, i have the following command:

$(eval n = parseFloat(`$(1)`); c = Math.round(n*(1/1.51)*100)/100; isNaN(n)? `Si quieres saber tu estatura en Sistema de Unidades Reis, coloca el comando "!Reis" junto con tu estatura`:`$(user) mide ${c} Reis de altura`)

used to convert meters to another unit of measure, the problem is that it doesn’t work when someone uses comma instead of period as decimal, I know there is the “replace” function to solve this problem, but it doesn’t work for me, maybe someone who knows more can help me.

For the one who is interested and does not quite understand the command.
If someone puts the command next to the number, they will operate the number; if they put a character that is not a number, they put a text that explains how to use the command.

Use

.replace(`,`,`.`).parseFloat()
1 Like

I already tried to implement that function but I can’t, could you help me to implement it correctly in the command written above, in fact this command you helped me to create it, I’m not very good with commands, sorry for bothering you a lot heh

Sorry bout that this should do it:

$(eval n = parseFloat(`$(1)`.replace(`,`,`.`)); c = Math.round(n*(1/1.51)*100)/100; isNaN(n)? `Si quieres saber tu estatura en Sistema de Unidades Reis, coloca el comando "!Reis" junto con tu estatura`:`$(user) mide ${c} Reis de altura`)
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.