0

I'm used to using Visual Studio and when programming mathematical equations it's possible to build a program that allows for both commas and decimals to be used (obviously handy, pending on the region of the world you live in). However, the project now at hand is written in HTML and JavaScript, but I have no idea how to cater for both the use of decimals and commas in these languages how is that done...

example of problem:

<!DOCTYPE html>
<html>

<head>

<script>
function MyDecimal() {
var FirstNum = "1.5";
var SecondNum = "2"
var Result = (FirstNum * SecondNum);
alert("Decimal Result: " + Result);
}

function MyComma() {
var FirstNum = "1,5";
var SecondNum = "2"
var Result = (FirstNum * SecondNum);
alert("Comma Result: " + Result);
}

</script>

</head>
<body>

<button onclick="MyDecimal()">Decimals</button>
<button onclick="MyComma()">Comma</button> 

</body>
</html>
OldProgrammer
  • 11,263
  • 3
  • 25
  • 42
LabRat
  • 1,927
  • 10
  • 51
  • 89
  • Okay i did the following as a test but still end up with decimal? – LabRat Apr 26 '22 at 19:09

0 Answers0