I am trying to add 4 numbers together, but instead of give it like this (0.00049358 + 0.13645312 + 0.1000 + .2000 = 0.4369467) but it gives me this result ( 0.000493580.136453120.10000.2000) when i press button, what is wrong with my code
<script>
function add1(){
var num20= document.getElementById("result1").value;
var num21= document.getElementById("result3").value;
var num22= document.getElementById("result6").value;
var num23= document.getElementById("result8").value
var result9 = num20 + num21 + num22 + num23;
document.getElementById("result9").value = result9.toLocaleString('en-US',{ maximumFractionDigits: 8 });
}
</script>
When you get them from the DOM, those values are passed as string, so as for JS is concerned you are concatenating strings, rather than sum up numbers.
You probably want to convert the values into floats.