You don't have to change your markup, you can do this :
['firefox','chrome'].forEach(function(id, index){
var canvas = document.getElementById(id);
var context = canvas.getContext('2d');
context.beginPath();
context.arc(64, 64, 60, 1.5*Math.PI, (index+1)*0.3*Math.PI, true);
context.lineWidth = 8;
context.lineCap = "round";
context.strokeStyle = '#c5731e';
context.stroke();
});
You don't have to duplicate the code or to call a function, you just have to add elements in the array.
If you can't infer the angle from the index, then,
- either you want to "hardcode" the data, then use a function (see other answer)
- or you want to manage the data as data.
In the latter case, you can do something like this :
var data = [
{id:'firefox', angle:33},
{id:'chrome', angle:43}
];
data.forEach(function(e){
var canvas = document.getElementById(e.id);
var context = canvas.getContext('2d');
context.beginPath();
context.arc(64, 64, 60, 1.5*Math.PI, e.angle, true);
context.lineWidth = 8;
context.lineCap = "round";
context.strokeStyle = '#c5731e';
context.stroke();
});