I am making a resume in HTML5 with the help of svg.js. I have made 5 labels like this:
var las = lang.text(function(add){
add.tspan('Läsa').dx(178).dy(145)
})
same thing for tal, skr, lys
and ord
To make as DRY code as possible I then style them like this:
var labels = [las, tal, skr, lys, ord]
labels.forEach(function(lab){
lab.font({
family: 'Helvetica',
size: 18
})
})
Now, my question is mostly about style, but what are the ways to go about this?
What I would like to do is just call forEach
directly on the array without having to clutter with variables, like this:
[las, tal, skr, lys, ord].forEach(function(lab){
lab.font({
family: 'Helvetica',
size: 18
})
})
But that doesn't work, although I don't really understand why. The MDN article for the error message doesn't make me any wiser. Sorry if this question seems silly, but either my google-fu isn't good enough or this really is so silly that no one bothered to ask it before :P