We would like to know how to apply math to values in a String array.
<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'>
<!-- ww w . j ava 2s . c o m-->
var myarray = ["5,35.0",
"15,45.0",
"25,45.0",
"35,50.0",
"45,60.0",
"55,65.0",
"65,60.0",
"75,60.0",
"85,70.0",
"95,80.0"];
var out = myarray.map(function(el) {
var xy = el.split(',').map(Number);
xy[1] = (xy[1] * 2).toFixed(1);
return xy.join(',');
});
console.log(out)
</script>
</head>
<body>
</body>
</html>
The code above is rendered as follows: