Try using a map
function on the array at the point where you need to make the calculations. Once you have the array so that each item is in the format that you want, you can map through the array and divide each item by 2.2.
E.g.
arr.map((item) => {
return item/2.2;
}) // at this point you could chain on 'join("\n")' or whatever
If I’m understanding you correctly, you want to make an array out of the data you have, then perform a calculation on each piece of that data, and then do something else with it. If so, then the built in javascript map
function is the way to go.
Note: I use ES6 fat arrow syntax for the function inside map, obviously you could just use an anonymous function with map(function(item) {...});
14
solved Javascript – use an array to calculate some coordinates