I currently struggle to program a receipt calculator. I want to map over an array with a specific value, then round the numbers and convert they to a string with commas instead of dots.
let ingredients = [0.02, 0.05, 0.5, 1.2];
let map = ingredients.map(x => x * 6);
for (let entry of map)
{
entry.toFixed(2).replace(".", ",");
console.log(entry);
}
This is what I get using a quantity of 6 on the mapping procedure:
0.12; 0.30000000000000004; 3; 7.199999999999999
But instead, I want it to be like:
0,12; 0,3; 3; 7,2
ingredients, notingridients.