Answer the question
In order to leave comments, you need to log in
CoffeeScript for loop?
function createGrid( section, dimensions ) {
var grid = new GridLayout({
dimensions: dimensions
});
var surfaces = [];
grid.sequenceFrom(surfaces);
for(var i = 0; i < dimensions[0] * dimensions[1]; i++) {
surfaces.push(new Surface({
content: section + ' ' + (i + 1),
size: [undefined, undefined],
properties: {
backgroundColor: "hsl(" + (i * 360 / 8) + ", 100%, 50%)",
color: "#404040",
textAlign: 'center'
}
}));
}
return grid;
}
for(var i = 0; i < dimensions[0] * dimensions[1]; i++)
in Coffee? Thanks in advance for your help!
Answer the question
In order to leave comments, you need to log in
In coffeescript, the for loop can only walk through objects/lists/generators.
For your case, you will have to use while:
i = 0
while i < dimensions[0] * dimensions[1]
# ...
i += 1
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question