A
A
Anton2017-07-10 18:26:30
JavaScript
Anton, 2017-07-10 18:26:30

How to put the result of this loop into a function?

Good day everyone!
I can’t figure it out (
I’m working with the snap.svg plugin, I need to somehow shove each object in the loop into a function under the loop

for (var i = 0; i < svg.length; i++) {
        var x = svg[i].coord_x
        var y = svg[i].coord_y
        var rect = s.rect(x, y, 20, 20).attr({
          class: 'seat',
          id: svg[i].id
        })
      }
//////////////////////
var set = s.g( каждый элемент из цикла );

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Stalker_RED, 2017-07-10
@Ooos

var set = [];
for (...) {
  set.push(rect);
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question